Timeline not waiting for data to come from service and throwing errors in console.
Closed this issue · 4 comments
Cannot read property 'nativeElement' of undefined
at HorizontalTimelineComponent.setDatePosition (horizontal-timeline.component.ts:332)
at HorizontalTimelineComponent.initTimeline (horizontal-timeline.component.ts:246)
at HorizontalTimelineComponent.initView (horizontal-timeline.component.ts:321)
at HorizontalTimelineComponent.set [as timelineElements] (horizontal-timeline.component.ts:103)
at updateProp (core.js:12619)
at checkAndUpdateDirectiveInline (core.js:12326)
at checkAndUpdateNodeInline (core.js:13893)
at checkAndUpdateNode (core.js:13836)
at debugCheckAndUpdateNode (core.js:14729)
at debugCheckDirectivesFn (core.js:14670)
Thank you so much for your response.
Here is the code
In My service:
public getAllData(nms: string): Observable {
return this.http
.get(/api/toy/123);
}
In my component:
timeline: TimelineElements[]
//If I manually set the values here it works
ngOnInit() {
this._dataService.getAllData().subscribe(
data => {
this.timeline = data; // When loading data from here I get the error
},
err => console.error(err),
() => console.info('done loading data'),
);
}
See #3 and #2 any my comment in #2 (comment)
Thanks I was able to make it work by calling cdr change method after loading data.