I want to render my data widget only after a promise returns a value. But I am running into a problem, I am currently am not able to see any return value from my promise and my data widget does not get rendered as well.I am doing this login in my constructor.
My plunker link is as below in case you want to look into the code https://plnkr.co/edit/kxMqwFZ1T5tU4xRcqomW?p=preview
constructor(myService: SummaryService) {
this.selectedYear = (new Date()).getFullYear() + "";
//Get years
myService.getSummaryYears().then(
response => {
this.summaryYears = response;
console.log(this.summaryYears);
this.createPivotGrid(myService);
}
).catch(error => {
console.log("Unable to get years, error => " + error);
})
}
Service calls
@Injectable()
export class SummaryService {
getSummaries():Promise<Response> {
return new Promise(resolve =>
setTimeout(() => resolve(summaries), 5000)
);
}
getSummaryYears(): Promise<Response> {
return new Promise(resolve =>
setTimeout(() => resolve(summaryYears), 5000)
);
}
}