【发布时间】:2019-04-09 16:08:34
【问题描述】:
我正在尝试获取集合的 ID 以在离子页面中使用它:
这是我的界面:
export interface Item {
categoryOfPost: string;
imageUrl: string;
nameOfPost: string;
cityOfPost: string;
createdDate: string;
currencyOfPost: string;
priceOfPost: number;
typeOfPost: number;
statusOfPost: string;
id?: string;
}
private itemsCollection: AngularFirestoreCollection<Item>;
items: Observable<Item[]>;
这是getPosts函数的内容
this.itemsCollection = this.afs.collection('posts', ref => ref.orderBy('createdDate', 'desc'));
this.items = this.itemsCollection.valueChanges();
当我想查看我使用的内容时:
<ion-card style="margin-bottom: 25px; background-color: burlywood" *ngFor="let item of items | async">
<ion-item text-wrap style="margin-bottom: 25px; background-color: burlywood">
<ion-list >
<ion-item>
<img src="{{ item.imageUrl }}">
cityOfPost: {{ item.id }}
<button ion-button (click)="detailpage(item.id)">click to test </button>
</ion-item>
</ion-list>
</ion-item>
</ion-card>
我可以在 HTML 上显示除未定义的 ID 之外的所有内容 ???? 正确的显示方式是什么???
谢谢。
【问题讨论】:
-
为这个基本问题创建了一个函数。它位于bottom of this page。不知道为什么这不是 AngularFire2 的一部分...
标签: typescript firebase google-cloud-firestore angularfire2