【发布时间】:2019-05-26 19:08:45
【问题描述】:
我正在学习 Observables 如何通过 Angular 和 Google Firestore 工作。
this.allinvoicesCollection = this.afs.collection('clients').doc(this.clientId).collection('inbox').valueChanges();
this.allinvoicesCollection.subscribe(val => {
this.fileUrl = val[this.currentIndex].downloadURL;
})
我正在使用上面的代码获取 fileUrl。
我想在变量“this.currentIndex”发生变化时更新fileUrl,但是上面的代码显然没有实现这一点。
我知道这只会在集合中的文档发生更改时触发。检测到“this.currentIndex”的变化时如何触发它?我应该提一下,“this.currentIndex”不是 Observable,只是用户更改的简单数字变量。
【问题讨论】:
标签: angular google-cloud-firestore observable