Hi
Can anybody please learn me why this.selectedPage[0].PageText; is working in promise but is not accessible out of it !? the array is not empty.
Runtime Error: Uncaught (in promise): TypeError: Cannot read property ‘0’ of undefined
LoadPage(index: number){
this.db.getStoryPage(this.selectedStory.st_ID,index).then((pagedata)=>{
this.selectedPage = [];
this.selectedPage = pagedata;
//is working here
this.PageText = this.selectedPage[0].PageText;
}).catch((err)=>{console.error(err)});
//is not accessible here:
this.PageText = this.selectedPage[0].PageText;
}