本文整理匯總了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;
}