我是新的消防基地,目前工作在一个网站。我想访问我的Firebase数据库,更确切地说,是带有“淘汰赛”小节的锦标赛部分。在本节中,我希望找到并返回该赛事的属性值小于16的属性“数字”。如果有,那么我想为该锦标赛添加一个新的订阅者。如果没有,我想增加一个新的锦标赛淘汰赛部分。
我现在只有下面的代码在我的tournaments.service文件中。我连接到db的淘汰赛部分,但是我不知道如何返回属性小于16的锦标赛。
(下面,我还添加了一个带有数据库结构的屏幕截图)

@Injectable()
export class TournamentsService {
constructor(private db: AngularFireDatabase) {
}
getOrCreateTournament(type){
// type is 'knockout' in this case (like in the database section, see picture)
let tournamentWithLessThan16 = this.db.list('/tournaments/' + type );
}
}发布于 2017-12-13 11:40:34
你应该订阅你的功能:
@Injectable()
export class TournamentsService {
constructor(private db: AngularFireDatabase) {
}
getOrCreateTournament(type){
// type is 'knockout' in this case (like in the database section, see
picture)
let tournamentWithLessThan16 = this.db.list('/tournaments/' + type).map(items => items.map(item => item));
tournamentWithLessThan16.subscribe(items => console.log(items));
}
}https://stackoverflow.com/questions/47744736
复制相似问题