本文整理汇总了TypeScript中angularfire2/database.AngularFireObject类的典型用法代码示例。如果您正苦于以下问题:TypeScript AngularFireObject类的具体用法?TypeScript AngularFireObject怎么用?TypeScript AngularFireObject使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了AngularFireObject类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。
示例1: getDiff
getDiff(id: string): Observable<Array<Diff>> {
const obj: AngularFireObject<Array<Diff>> = this.db.object('diffs/' + id);
return obj.valueChanges();
}
开发者ID:nrjchnd,项目名称:startup-os,代码行数:4,代码来源:firebase.service.ts
示例2: onChange
onChange(e: any, key: string) {
this.page = this.db.object('/pages/' + key);
if (e.checked) {
this.page.update({published: true});
} else {
this.page.update({published: false});
}
}
开发者ID:mogeta,项目名称:firebase-cms,代码行数:8,代码来源:admin-pages.component.ts
示例3: ngOnInit
ngOnInit() {
this.theme.valueChanges().subscribe((item:any) => {
if (item && item.siteName) {
this.siteName = item.siteName;
}
});
}
开发者ID:mogeta,项目名称:firebase-cms,代码行数:7,代码来源:admin-theme.component.ts
示例4: saveTheme
saveTheme(newSiteName: string) {
this.theme.update({
siteName: newSiteName
});
let snackBarRef = this.snackBar.open('Theme updated', 'OK!', {
duration: 3000
});
}
开发者ID:mogeta,项目名称:firebase-cms,代码行数:9,代码来源:admin-theme.component.ts
示例5:
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;
}
});
开发者ID:mogeta,项目名称:firebase-cms,代码行数:55,代码来源:add-product.component.ts
示例6: addProduct
addProduct(newTitle: string, newPrice: string, newCategory: any, newWeight: number, newDescription: string, newPublished: boolean) {
if (!newPublished) {
newPublished = false;
}
if (newTitle && newPrice && newDescription && this.currentAdmin.uid) {
let productObject = {
url: this.globalService.slugify(newTitle),
dateUpdated: Date.now().toString(),
rdateUpdated: (Date.now() * -1).toString(),
title: newTitle,
thumbnail: this.newThumbnail ? this.newThumbnail : null,
description: newDescription,
price: newPrice,
published: newPublished,
updatedBy: this.currentAdmin.uid,
weight: newWeight,
category: newCategory ? newCategory : null,
entityKey: this.editMode && this.productKey ? this.productKey : null
};
// if (this.imageUrl && !this.newThumbnail) {
// this.deleteImageRef();
// }
if (this.editMode && this.productKey) {
this.currentProduct = this.db.object('/products/' + this.productKey);
this.currentProduct.update(productObject);
this.updateCategory(this.ogCategory, this.newCategory, this.productKey);
} else {
this.products.push(productObject).then((item) => {
if (this.newCategory) {
this.db.object('/products/' + item.key + '/entityKey').set(item.key);
this.db.object('/categories/' + this.newCategory + '/products/' + item.key).set(Date.now().toString());
}
});
}
let snackBarRef = this.snackBar.open('Product saved', 'OK!', {
duration: 3000
});
}
this.validateFields(newTitle, newDescription, newPrice);
}
开发者ID:mogeta,项目名称:firebase-cms,代码行数:46,代码来源:add-product.component.ts
示例7:
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;
}
});
开发者ID:mogeta,项目名称:firebase-cms,代码行数:43,代码来源:add-post.component.ts
示例8: addPost
addPost(newURL: string, newDate: string, newTitle: string, newBody: string, newPublished: boolean) {
if (!newPublished) {
newPublished = false;
}
if (newURL && newDate && newTitle && newBody && this.currentAdmin.uid) {
let date = new Date(newDate);
let dateTime = date.getTime();
let postObject = {
url: newURL,
dateUpdated: Date.now().toString(),
rdateUpdated: (Date.now() * -1).toString(),
date: dateTime,
title: newTitle,
thumbnail: this.newThumbnail ? this.newThumbnail : null,
body: newBody,
published: newPublished,
updatedBy: this.currentAdmin.uid,
entityKey: this.editMode && this.postKey ? this.postKey : null
};
// if (this.imageUrl && !this.newThumbnail) {
// this.deleteImageRef();
// }
if (this.editMode && this.postKey) {
this.currentPost = this.db.object('/posts/' + this.postKey);
this.currentPost.update(postObject);
} else {
this.posts.push(postObject).then((item) => {
this.db.object('/posts/' + item.key + '/entityKey').set(item.key);
});
}
let snackBarRef = this.snackBar.open('Post saved', 'OK!', {
duration: 3000
});
}
this.validateFields(newURL, newTitle, newBody, newDate);
}
开发者ID:mogeta,项目名称:firebase-cms,代码行数:42,代码来源:add-post.component.ts
示例9: 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;
}
开发者ID:tequila1410,项目名称:AngularBlogApp,代码行数:10,代码来源:posts-list.service.ts
注:本文中的angularfire2/database.AngularFireObject类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论