Not able to invoke subscribe function 2nd times

Dear All,

I am facing issues while calling subscribe function first time its calling and getting records but second time when I back to the same page then I am not getting any data.

Step 1: Created Service (urx.service.ts)

private userTrxCollection: AngularFirestoreCollection;
private userTrxs: Observable<UserTrx>;
constructor(public db: AngularFirestore) {
this.userTrxCollection = db.collection(‘userTrxs’);
this.userTrxs = this.userTrxCollection.snapshotChanges().pipe(
map(actions => {
return actions.map(a => {
const data = a.payload.doc.data();
const id = a.payload.doc.id;
return { id, …data };
});
})
);
}

Step 2: created one page and import this service (urx.page.ts)

ngOnInit() {

this.TrxID=this.route.snapshot.params['refTrxId'];
if(this.TrxID){
  this.loadUserTrx();
}

async loadUserTrx() {
const loading = await this.loadingController.create({
message: ’ ’

});

await loading.present();
this.userCashTrx.getUserTrxs().subscribe(ucash=>{
loading.dismiss();
this.userTrxs = ucash;
console.log(this.userTrx);
this.userTrxs = this.userTrxs.filter(res=> res.userEmail == this.userEmail)
for(let tx of this.userTrxs){
this.total_Trx = this.total_Trx + tx.cost;
}
this.total_Trx=Math.round(this.total_Trx * 100) / 100;
console.log(this.total_Trx);
this.total_Trx_Balance = this.total_WalletAmt - this.total_Trx;
});

}

Login the page and got all the data so far its fine now i cam back to this page from another one this subscribe function not working for me.

Please help me out.

I have tried ngDestroy function to unsubscribe collection but no luck.

Your help would be appreciated

please let me know if you need more clarity of the above.

Thanks

Mozib

Thanks for this information. It is very useful