从firestore文档引用从angular获取数据

从firestore文档引用从angular获取数据,angular,google-cloud-firestore,Angular,Google Cloud Firestore,我有下面的代码,直接从angular从firestore获取数据。 您可以查看console.log(data.city);我有城市的文件参考。 那么,我如何从angular中的文档引用中访问数据呢 Firestore中的文档引用不会立即提供数据。您必须使用该文档引用并从firebase获取数据 这就像手动获取引用文档的数据一样。 比如说, this.afs.collection('users').doc('doc_id').get().then(result => console.log

我有下面的代码,直接从angular从firestore获取数据。 您可以查看console.log(data.city);我有城市的文件参考。 那么,我如何从angular中的文档引用中访问数据呢


Firestore中的文档引用不会立即提供数据。您必须使用该文档引用并从firebase获取数据

这就像手动获取引用文档的数据一样。 比如说,

this.afs.collection('users').doc('doc_id').get().then(result => console.log(result.data()));;//if you want to access a specific document
如果你已经有了一个参考资料(比如你的案例中的城市)

如果数据对象抛出任何无效引用异常,则可以使用:any数据类型

希望这有帮助

data.city.get().then(result => console.log(result.data()));