Chart.js not showing in Angular2 if it doesn't exist on the main page

后端 未结 2 1431
夕颜
夕颜 2020-12-02 00:25

It seems fine whenever I dump the chart to the main app.component.html, but as soon as I use it in a child component and have the app routed to it, the chart doesn\'t show u

2条回答
  •  醉酒成梦
    2020-12-02 00:34

    There was a breaking change in Angular 2.0.0-beta.3 regarding ElementRef https://github.com/angular/angular/blob/master/CHANGELOG.md#200-beta3-2016-02-03. Instead of using ElementRef inside the constructor you should look at ngOnInit as a LifeCycle hook https://angular.io/docs/ts/latest/guide/lifecycle-hooks.html

提交回复
热议问题