After executing ngOnChanges, the method _generateLocationFormForApproval is called, resulting in the output this.absoluteUri. Following this, _pageEventDealsForApprovalList is invoked. However, when trying to access the value of this.absoluteUri inside _pageEventDealsForApprovalList, it returns undefined despite having a value previously set.
What could be causing this.absoluteUri to be undefined inside _pageEventDealsForApprovalList?
Could it be related to asynchronous calls?
#code
ngOnChanges(changes: SimpleChanges): void {
if(this.dealId) {
this._generateLocationFormForApproval();
this._pageEventDealsForApprovalList();
}
}
private _generateLocationFormForApproval() {
this.dealService.generateLocationSubmission(this.dealId)
.subscribe({
next: (res) => {
if (res.isSuccess) {
this.absoluteUri = res.data.absoluteUri;
}
},
error: err => this.notificationService.showError(err),
complete: noop,
});
}
private _pageEventDealsForApprovalList() {
console.log("1")
console.log("this.absoluteUrithis.absoluteUri" , this.absoluteUri)
this.searchInput = '';
const status = [DEAL.STATUS.FORAPPROVAL, DEAL.STATUS.APPROVED]
this.dealType = [];
this.isLoading = true;
this.dealService
.getAllDeals(
status,
this.accountId,
this.transaction.id,
this.table.pageIndex + 1,
this.table.pageSize,
this.searchInput,
this.table.sortParams,
this.table.sortDirs,
this.dealType
)
.pipe(finalize(() => (this.isLoading = false)))
.subscribe((res) => {
if(res) {
console.log("this.uri" , this.absoluteUri)
}
}, (err) => this.notificationService.showError(err)
);
}