0👍
✅
Make sure to not use *ngIf
, it destroys your canvas and the ElementRef. Hide it with CSS.
Also, I use getContext('2d')
<canvas #canvas>{{ chart }}</canvas>
@ViewChild('canvas') canvas: ElementRef;
this.canvas.nativeElement.getContext('2d')
Source:stackexchange.com