本文整理汇总了TypeScript中angularfire2/database.AngularFireObject.valueChanges方法的典型用法代码示例。如果您正苦于以下问题:TypeScript AngularFireObject.valueChanges方法的具体用法?TypeScript AngularFireObject.valueChanges怎么用?TypeScript AngularFireObject.valueChanges使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类angularfire2/database.AngularFireObject
的用法示例。
在下文中一共展示了AngularFireObject.valueChanges方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: ngOnInit
ngOnInit() {
this.theme.valueChanges().subscribe((item:any) => {
if (item && item.siteName) {
this.siteName = item.siteName;
}
});
}
示例2:
this.route.params.subscribe((params: Params) => {
if (params && params.key) {
this.editMode = true;
this.productKey = params.key;
if (this.router.url.includes('approval')) {
this.currentProduct = this.db.object('/approvals/products/' + params.key);
this.db.object('/approvals/products/' + params.key).valueChanges().take(1).subscribe((p:any) => {
if (p.category) {
this.ogCategory = p.category;
}
});
this.db.object('/approvals/products/' + this.productKey).valueChanges().subscribe((approvalProduct:any) => {
this.entityObject = approvalProduct;
});
} else {
this.currentProduct = this.db.object('/products/' + params.key);
this.db.object('/products/' + params.key).valueChanges().take(1).subscribe((p:any) => {
if (p.category) {
this.ogCategory = p.category;
}
});
// check to see if any approvals are awaiting on this product
this.db.list('/approvals/products', ref => ref.orderByChild('entityKey').equalTo(params.key)).valueChanges()
.subscribe((approval:any) => {
if (approval.length > 0 && approval[0]) {
this.awaitingApproval = approval[0].key;
}
});
}
this.currentProduct.valueChanges().subscribe((p:any) => {
this.newTitle = p.title;
this.newDescription = p.description;
this.newPrice = p.price;
this.newPublished = p.published;
this.newCategory = p.category;
this.newWeight = p.weight;
if (p.thumbnail) {
this.imageUrl = p.thumbnail;
this.newThumbnail = p.thumbnail;
}
});
} else {
this.newTitle = null;
this.newThumbnail = null;
this.newDescription = null;
this.newPrice = null;
this.newCategory = null;
this.newWeight = 0;
this.newPublished = false;
}
});
示例3:
this.route.params.subscribe((params: Params) => {
if (params && params.key) {
this.editMode = true;
this.postKey = params.key;
if (this.router.url.includes('approval')) {
this.currentPost = this.db.object('/approvals/posts/' + params.key);
this.db.object('/approvals/posts/' + this.postKey).valueChanges().subscribe((approvalPost:any) => {
this.entityObject = approvalPost;
});
} else {
this.currentPost = this.db.object('/posts/' + params.key);
// check to see if any approvals are awaiting on this post
this.db.list('/approvals/posts', ref => ref.orderByChild('entityKey').equalTo(params.key)).snapshotChanges()
.subscribe((approval:any) => {
if (approval.length > 0 && approval[0]) {
this.awaitingApproval = approval[0].key;
}
});
}
this.currentPost.valueChanges().subscribe((p:any) => {
this.newURL = p.url;
this.newDate = p.date;
this.newTitle = p.title;
this.newBody = p.body;
this.newPublished = p.published;
if (p.thumbnail) {
this.imageUrl = p.thumbnail;
this.newThumbnail = p.thumbnail;
}
});
} else {
this.newURL = null;
this.newDate = null;
this.newTitle = null;
this.newThumbnail = null;
this.newBody = null;
this.newPublished = false;
}
});
示例4: getPostById
/**
* Get post by id
* @param key
*/
getPostById(key: string): Observable<any> {
this.postRef = this.db.object(`posts/${key}`);
this.post = this.postRef.valueChanges();
return this.post;
}
示例5: getDiff
getDiff(id: string): Observable<Array<Diff>> {
const obj: AngularFireObject<Array<Diff>> = this.db.object('diffs/' + id);
return obj.valueChanges();
}