Here's my problem. A lot of examples of using Chartjs in Angular only assume that data is already there , and they render it in ngAfterViewInit
.
However, I can't figure out how to meet my requirements:
mat-spinner
document.getElementById('canvasId')
, since it's not rendered yet. ngAfterViewInit
, then I don't know when data is loaded, since it's indeterminate, and I encounter null reference for the properties of my data object. ngAfterViewInit
, then Angular complains that ExpressionChangedAfterItHasBeenCheckedError: Expression has changed after it was checked. Previous value: 'ngIf: undefined'. Current value: 'ngIf: true'
ExpressionChangedAfterItHasBeenCheckedError: Expression has changed after it was checked. Previous value: 'ngIf: undefined'. Current value: 'ngIf: true'
ExpressionChangedAfterItHasBeenCheckedError: Expression has changed after it was checked. Previous value: 'ngIf: undefined'. Current value: 'ngIf: true'
. This error is related to mat-spinner *ngIf='progress'
I'm stuck at this point on how to reconcile these requirements. Any help?
This post uses a service to get data and render the chart after the data is loaded. Hope it helps!
Angular Load Data from Service
I was getting the expression changed error but loading and executing in OnInit worked for me.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.