简体   繁体   English

Angular Firestore获取单个文档

[英]Angular firestore get single document

angular firestore get document giving error during assignment. 角度firestore获取分配过程中出错的文档。 data is visible in console log, but not working in other cases. 数据在控制台日志中可见,但在其他情况下不起作用。

码

安慰

You need to declare the product variable with its type 您需要使用其类型声明产品变量

product : Product; 

or

product : any;

EDIT: As yurzui mentioned in the above comment, you should use arrow function to refer the context, so that this.product will be defined 编辑:如上面的注释中提到的yurzui,您应该使用箭头函数来引用上下文,以便将this.product定义

We should use arrow function to retain context this . 我们应该用箭头功能是保持关联this ( get().then((doc) => ) As yurzui commented. get().then((doc) => )正如yurzui所说。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM