本文整理汇总了TypeScript中angularfire2/database.AngularFireDatabase.list方法的典型用法代码示例。如果您正苦于以下问题:TypeScript AngularFireDatabase.list方法的具体用法?TypeScript AngularFireDatabase.list怎么用?TypeScript AngularFireDatabase.list使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类angularfire2/database.AngularFireDatabase
的用法示例。
在下文中一共展示了AngularFireDatabase.list方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: constructor
constructor(
private route: ActivatedRoute,
private router: Router,
private db: AngularFireDatabase,
private sanitizer: DomSanitizer,
private spotifyService: SpotifyService,
private soundcloudService: SoundcloudService) {
this.sanitizer = sanitizer;
this.id = this.route.snapshot.params.id;
this.itemsRef = db.list('items/' + this.id);
this.forkedItems = this.itemsRef.valueChanges();
this.items = db.list('items');
// this.items = af.database.list('/items');
this.playlist = [];
this.forkedItemsSubsciption = this.forkedItems
.subscribe(items=> {
items.forEach((item:any) => {
if(item.url && item.embed_url) {
this.playlist.push({url: item.url, embed_url: item.embed_url, image_url: item.image_url});
}
if(item.title) {
this.forkedTitle = item.title;
this.title = item.title;
}
if(item.fork_count !== undefined) {
this.fork_count = item.fork_count+1;
this.forkKey = item.$key;
}
});
});
}
示例2: constructor
constructor(
public af: FirebaseApp,
public db: AngularFireDatabase,
public snackBar: MdSnackBar,
public globalService: GlobalService,
public router: Router,
public route: ActivatedRoute,
private fb: FirebaseApp,
public dialog: MdDialog
) {
this.newPublished = false;
this.products = db.list('/products');
this.categories = db.list('/categories').snapshotChanges();
this.globalService.admin.subscribe(admin => {
this.currentAdmin = admin;
let adminApprovalProducts = this.db.list('/approvals/products/', ref => ref.orderByChild('updatedBy').equalTo(this.currentAdmin.uid));
adminApprovalProducts.valueChanges().subscribe(response => {
console.log(!response);
});
});
this.storageRef = af.storage().ref();
}
示例3: submitForModeration
submitForModeration(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 approvalObject = {
entityKey: this.router.url.includes('approval') ? this.entityObject.entityKey : this.postKey,
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
};
if (this.editMode && this.postKey) {
this.currentModeratedPosts = this.db.list('/approvals/posts/');
let adminApprovalPosts = this.db.list('/approvals/posts/', ref => ref.orderByChild('updatedBy').equalTo(this.currentAdmin.uid)).valueChanges();
adminApprovalPosts.take(1).subscribe((approvals:any) => {
let matchingApprovals = [];
if (this.router.url.includes('approval')) {
matchingApprovals = approvals.filter((match) => {
return match.entityKey === this.entityObject.entityKey;
});
} else {
matchingApprovals = approvals.filter((match) => {
return match.entityKey === this.postKey;
});
}
if (matchingApprovals.length === 0 || !this.router.url.includes('approval')) {
this.currentModeratedPosts.push(approvalObject);
} else {
this.db.object('/approvals/posts/' + this.postKey).update(approvalObject);
}
});
} else {
this.db.list('/approvals/posts/').push(approvalObject);
}
let snackBarRef = this.snackBar.open('Post submitted for moderation', 'OK!', {
duration: 3000
});
snackBarRef.onAction().subscribe(() => {
this.router.navigateByUrl('admin/approvals');
});
}
this.validateFields(newURL, newTitle, newBody, newDate);
}
示例4: submitForModeration
submitForModeration(newTitle: string, newPrice: string, newCategory: any, newWeight: number, newDescription: string, newPublished: boolean) {
if (!newPublished) {
newPublished = false;
}
if (newTitle && newPrice && newDescription && this.currentAdmin.uid) {
let approvalObject = {
entityKey: this.router.url.includes('approval') ? this.entityObject.entityKey : this.productKey,
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,
weight: newWeight,
updatedBy: this.currentAdmin.uid,
category: newCategory ? newCategory : null
};
if (this.editMode && this.productKey) {
this.currentModeratedProducts = this.db.list('/approvals/products/');
let adminApprovalProducts = this.db.list('/approvals/products/', ref => ref.orderByChild('updatedBy').equalTo(this.currentAdmin.uid)).valueChanges();
adminApprovalProducts.take(1).subscribe((approvals:any) => {
let matchingApprovals = [];
if (this.router.url.includes('approval')) {
matchingApprovals = approvals.filter((match) => {
return match.entityKey === this.entityObject.entityKey;
});
} else {
matchingApprovals = approvals.filter((match) => {
return match.entityKey === this.productKey;
});
}
if (matchingApprovals.length === 0 || !this.router.url.includes('approval')) {
this.currentModeratedProducts.push(approvalObject);
} else {
this.db.object('/approvals/products/' + this.productKey).update(approvalObject);
}
});
} else {
this.db.list('/approvals/products/').push(approvalObject);
}
let snackBarRef = this.snackBar.open('Product submitted for moderation', 'OK!', {
duration: 3000
});
snackBarRef.onAction().subscribe(() => {
this.router.navigateByUrl('admin/approvals');
});
}
this.validateFields(newTitle, newDescription, newPrice);
}
示例5: constructor
constructor(
public db: AngularFireDatabase,
public route: ActivatedRoute,
public router: Router,
private title: Title,
private meta: Meta
) {
this.categories = db.list('/categories').valueChanges();
this.products = db.list('/products', ref => ref.orderByChild('published').equalTo(true)).valueChanges();
this.categoryObject = {};
}
示例6: constructor
constructor(
public db: AngularFireDatabase,
public snackBar: MdSnackBar,
public globalService: GlobalService,
public router: Router,
public route: ActivatedRoute
) {
this.states = globalService.states;
this.statuses = globalService.orderStatuses;
this.orders = db.list('/orders');
this.users = db.list('/users');
this.order = { shipping: {}, billing: {} };
}
示例7: submitForModeration
submitForModeration(newName: string, newWeight: number) {
if (newName && this.currentAdmin.uid) {
let approvalObject = {
entityKey: this.router.url.includes('approval') ? this.entityObject.entityKey : this.categoryKey,
name: newName,
weight: newWeight,
slug: this.globalService.slugify(newName),
dateUpdated: Date.now().toString(),
rdateUpdated: (Date.now() * -1).toString(),
updatedBy: this.currentAdmin.uid,
products: this.newProducts ? this.newProducts : null
};
if (this.editMode && this.categoryKey) {
this.currentModeratedCategories = this.db.list('/approvals/categories/');
let adminApprovalCategories = this.db.list('/approvals/categories/', ref => ref.orderByChild('updatedBy').equalTo(this.currentAdmin.uid)).valueChanges();
adminApprovalCategories.take(1).subscribe((approvals:any) => {
let matchingApprovals = [];
if (this.router.url.includes('approval')) {
matchingApprovals = approvals.filter((match) => {
return match.entityKey === this.entityObject.entityKey;
});
} else {
matchingApprovals = approvals.filter((match) => {
return match.entityKey === this.categoryKey;
});
}
if (matchingApprovals.length === 0 || !this.router.url.includes('approval')) {
this.currentModeratedCategories.push(approvalObject);
} else {
this.db.object('/approvals/categories/' + this.categoryKey).update(approvalObject);
}
});
} else {
this.db.list('/approvals/categories/').push(approvalObject);
}
let snackBarRef = this.snackBar.open('Category submitted for moderation', 'OK!', {
duration: 3000
});
snackBarRef.onAction().subscribe(() => {
this.router.navigateByUrl('admin/approvals');
});
}
this.validateFields(newName);
}
示例8: constructor
constructor(
public db: AngularFireDatabase,
private title: Title,
private meta: Meta
) {
this.categories = db.list('/categories', ref => ref.orderByChild('weight').limitToLast(999)).valueChanges();
}
示例9:
this.route.params.subscribe((params: Params) => {
if (params && params.key) {
this.editMode = true;
this.categoryKey = params.key;
if (this.router.url.includes('approval')) {
this.currentCategory = this.db.object('/approvals/categories/' + params.key);
this.db.object('/approvals/categories/' + this.categoryKey).valueChanges().subscribe((approvalCategory:any) => {
this.entityObject = approvalCategory;
});
} else {
this.currentCategory = this.db.object('/categories/' + params.key);
// check to see if any approvals are awaiting on this category
this.db.list('/approvals/categories', ref => ref.orderByChild('entityKey').equalTo(params.key)).snapshotChanges()
.subscribe((approval:any) => {
if (approval.length > 0 && approval[0]) {
this.awaitingApproval = approval[0].key;
}
});
}
this.currentCategory.subscribe(c => {
this.newName = c.name;
this.newWeight = c.weight;
if (c.products) {
this.newProducts = c.products;
}
});
} else {
this.newName = null;
this.newWeight = 0;
}
});
示例10: if
dialogRef.afterClosed().subscribe(result => {
this.selectedOption = result;
if (this.selectedOption === 'approve') {
if (entityObject.entityKey) {
let ogEntity = this.db.object('/' + entity + '/' + entityObject.entityKey);
ogEntity.valueChanges().take(1).subscribe((item:any) => {
if (entity === 'products' && item.category && entityObject.category) {
this.db.object('/categories/' + item.category + '/products/' + entityObject.entityKey).remove();
this.db.object('/categories/' + entityObject.category + '/products/' + entityObject.entityKey).set(Date.now().toString());
} else if (entity === 'products' && item.category && !entityObject.category) {
this.db.object('/categories/' + item.category + '/products/' + entityObject.entityKey).remove();
} else if (entity === 'products' && !item.category && entityObject.category) {
this.db.object('/categories/' + entityObject.category + '/products/' + entityObject.entityKey).set(Date.now().toString());
}
ogEntity.set(entityObject);
});
} else {
this.db.list('/' + entity).push(entityObject).then((item) => {
if (entity === 'products' && entityObject.category) {
this.db.object('/categories/' + entityObject.category + '/products/' + item.key).set(Date.now().toString());
}
});
}
this.db.object('/approvals/' + entity + '/' + ogKey).remove();
let snackBarRef = this.snackBar.open('Item approved', 'OK!', {
duration: 3000
});
}
});