Reputation: 33
When I try to execute this block of code this is what I get.
core.mjs:6485 ERROR Error: Uncaught (in promise): TypeError: Cannot read properties of undefined (reading 'showSpinner')
async ShowData() {
if(this.loading) {
return;
}
this.loading = true;
this.detailApp.showSpinner('Show Spinner');
try {
this.form.valueChanges.pipe(
distinctUntilChanged()
).subscribe(async changes =>{
await this.LandComponent.getAllData(changes.textName).then(data =>{
this.preview = data;
this.activePageDataChunk = this.preview.slice(0,this.pageSize);
}).catch(error =>{
console.log(error)
})
});
}
catch(e) {
console.error(e);
}
this.loading = false;
this.detailApp.hideSpinner();
}
// detailApp.ts
export interface detailApp {
showSpinner(text:string):void
}
Upvotes: 1
Views: 1828
Reputation: 2566
The problem in your code is that this.detailApp
is not initialized anywhere in the file, so it is undefined
Upvotes: 1