src / app / app.component.ts(31,43)中的AngularFire错误:错误TS2559:“名称”类型与“ GetOptions”类型没有共同的属性

时间:2019-01-27 16:43:59

标签: angular google-cloud-firestore angularfire2

我尝试从Firestore文档中获取数据。因此,我创建了这个:

export class AppComponent implements OnInit {
 title = 'HEIMATVOLL';

  blogeintrag = BLOGEINTRAG;
  selectedBlogeintrag: Blogeintrag;
  private itemDoc: AngularFirestoreDocument<MyObjectInterface>;
 item: Observable<MyObjectInterface>;
 constructor(private afs: AngularFirestore) {
this.itemDoc = afs.doc<MyObjectInterface>('Test/bA2cv4cJ3lvJ2f8ybTDM');
this.item = this.itemDoc.valueChanges();
 }


ngOnInit() {
console.log("fasdf1",this.itemDoc.get('name'));
}

onSelect(blogeintrag: Blogeintrag): void {
this.selectedBlogeintrag = blogeintrag;
}

}

在我的OnInit方法中,我尝试打印出文档键“名称”的值。不幸的是,我收到此错误:

  

错误TS2559:“名称”类型与“ GetOptions”类型没有共同的属性。

日志显示“未定义”。

如果有人可以解释我如何获得一定的价值,那就太好了。

0 个答案:

没有答案