shalugin / horizontal-timeline

Horizontal Timeline Component on Angular2
MIT License
39 stars 22 forks source link

Timeline not waiting for data to come from service and throwing errors in console. #6

Closed Pankesh88 closed 6 years ago

Pankesh88 commented 6 years ago

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)

shalugin commented 6 years ago

How can I reproduce?

Отправлено с моего телефона на Windows 10

От: Pankesh88 Отправлено: 15 мая 2018 г. в 19:48 Кому: shalugin/horizontal-timeline Копия: Subscribed Тема: [shalugin/horizontal-timeline] Timeline not waiting for data to comefrom service and throwing errors in console. (#6)

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) — You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub, or mute the thread.

Pankesh88 commented 6 years ago

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'), ); }

shalugin commented 6 years ago

See #3 and #2 any my comment in https://github.com/shalugin/horizontal-timeline/issues/2#issuecomment-296529033

Pankesh88 commented 6 years ago

Thanks I was able to make it work by calling cdr change method after loading data.