score:3

Accepted answer

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>

Related Query

More Query from same tag