正在刷新来自 FireStore GET 订阅的数据 - Angular - Firebase/FireStore
Refreshing data from FireStore GET subscription- Angular - Firebase/FireStore
我正在订阅位于 NgOnInit() 中的 Firestore 文档 "this.afs.collection('messaging').doc(email);"。在 Firestore 中创建另一个文档后,我想刷新数据。我对执行此操作的最佳方法感到有些困惑。我已尝试 "window.location.reload()",但我的 POST 操作没有完成。我也尝试过使用 changeDetector 也没有帮助。
组件
ngOnInit(){
const doc = this.afs.collection('messaging').doc(email);
doc.subscribe( usersData => { this.users = usersData });
`
`
模板
<ng-container *ngFor="let user of users;index as i">
{{user.payload.doc.data().displayName}}
</ng-container>
`
根据模式,我假设您使用 @angular/fire
。另外,您在这里处理的是幕后的 websockets,这意味着这里发生的一切都是实时发生的。也就是说,您无需刷新任何内容。
我正在订阅位于 NgOnInit() 中的 Firestore 文档 "this.afs.collection('messaging').doc(email);"。在 Firestore 中创建另一个文档后,我想刷新数据。我对执行此操作的最佳方法感到有些困惑。我已尝试 "window.location.reload()",但我的 POST 操作没有完成。我也尝试过使用 changeDetector 也没有帮助。
组件
ngOnInit(){
const doc = this.afs.collection('messaging').doc(email);
doc.subscribe( usersData => { this.users = usersData });
`
`
模板
<ng-container *ngFor="let user of users;index as i">
{{user.payload.doc.data().displayName}}
</ng-container>
`
根据模式,我假设您使用 @angular/fire
。另外,您在这里处理的是幕后的 websockets,这意味着这里发生的一切都是实时发生的。也就是说,您无需刷新任何内容。