我的 tabs.ts
下有一个观测对象ngOnInit() {
this.cartService.getCart(this.authId).subscribe(cart => {
this.cart = cart;
});
}
文件 cart.service.ts
下的cartService.getCartgetCart(authId: string): Observable<Cart> {
this.cartsCollection2 = this.afs.collection('carts', ref => ref.where('authId', '==', authId).where('status', '==', 'active'));
this.cart = this.cartsCollection2.snapshotChanges().pipe(
map(changes => {
return changes.map(action => {
const data = action.payload.doc.data() as Cart;
data.id = action.payload.doc.id;
return data;
});
})
);
return this.cart;
}
付款后,我将购物车状态更新为“已付款”,而不是“有效”,这会更新可观察结果。本质上,我的tabs.ts中的购物车现在应该为空。如何获取结果?