本文整理汇总了TypeScript中angularfire2/database.AngularFireList.snapshotChanges方法的典型用法代码示例。如果您正苦于以下问题:TypeScript AngularFireList.snapshotChanges方法的具体用法?TypeScript AngularFireList.snapshotChanges怎么用?TypeScript AngularFireList.snapshotChanges使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类angularfire2/database.AngularFireList
的用法示例。
在下文中一共展示了AngularFireList.snapshotChanges方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: constructor
constructor(
public navCtrl: NavController,
public alertCtrl: AlertController,
public database: AngularFireDatabase
) {
this.tasksRef = this.database.list('tasks');
this.tasks = this.tasksRef.snapshotChanges()
.map(changes => {
return changes.map(c => ({ key: c.payload.key, ...c.payload.val() }));
});
}
示例2:
this.sub = this.activatedRoute.params.subscribe((params:any) => {
this.id = params['id'];
this.itemsRef = db.list('/Raves/'+this.id);
this.itemsRef.snapshotChanges(['child_added'])
.subscribe(actions => {
actions.forEach(action => {
//console.log(action.type, action.key, action.payload.val());
if (action.key === 'url'){
this.url = this.domSanitizer.bypassSecurityTrustResourceUrl('https://w.soundcloud.com/player/?url='+action.payload.val()+'&color=000000&auto_play=false&hide_related=false&show_comments=false&show_user=false&show_reposts=false');
console.log(this.url)
}
if (action.key === 'image'){
this.image = action.payload.val();
console.log(this.image)
}
});
});
});
示例3: constructor
constructor(private router: Router, private readonly db: AngularFireDatabase) {
this.router = router;
this.itemsRef = db.list('items');
this.items = this.itemsRef.snapshotChanges();
}
示例4: constructor
constructor(private db : AngularFireDatabase) {
this.postsRef = db.list('posts');
this.posts = this.postsRef.snapshotChanges();
}
示例5: ngOnInit
ngOnInit(){
this.events = this.db.list('/Events');
this.events$ = this.events.snapshotChanges().map(changes => {
return changes.map(c => ({ key: c.payload.key, ...c.payload.val() }));
});
}
示例6: getCommentsByPostId
/**
* Get Array of comments
* @param postId
*/
getCommentsByPostId(postId: String): Observable<any[]> {
this.commentsRef = this.db.list('comments/' + postId);
this.comments = this.commentsRef.snapshotChanges();
return this.comments;
}