【发布时间】:2018-11-26 16:19:05
【问题描述】:
我正在尝试在输入字段中显示来自 Firestore 的数据,但最终出现错误
intem.services.ts
getItem(itemId) {
return this.afs.doc('items' + itemId);
}
item.component.ts
item;
constructor(
private router: Router,
private afs: AngularFirestore,
private route: ActivatedRoute,
private itemService: ItemService) {
const id = this.route.snapshot.paramMap.get('id');
if (id) {this.itemService.getItem(id).snapshotChanges().pipe(take(1), map(p => this.product = p));
}
item.component.html
<input #title="ngModel" [(ngModel)]="item.title" name="title" type="text" id="title" class="form-control">
【问题讨论】:
-
请提供您遇到的错误。一个最小的例子会有帮助
-
ERROR CONTEXT Object { view: {…}, nodeIndex: 13, nodeDef: {…}, elDef: {…}, elView: {…} } IntemFormComponent.html:6:12
-
您尝试过此处说明的修复方法吗? stackoverflow.com/questions/44879095/…
-
ERROR TypeError: _co.item is undefined
-
是,但没用
标签: angular firebase google-cloud-firestore