3👍
✅
The canvas
element will not be rendered (written to the DOM) until chart
is true
<div *ngIf="chart">
<canvas #canvas></canvas>
</div>
Because chart
is initially undefined
, the canvas ViewChild does not exist, which explains why "this.canvas is undefined".
Try removing *ngIf="chart" to test your chart.
<canvas #canvas></canvas>
Source:stackexchange.com