Friday, October 12, 2018

Angular 6 Component Require JSON ExpressionChangedAfterItHasBeenCheckedError


In an Angular 6 project, a simple component that gets json data from a local file generates error: ExpressionChangedAfterItHasBeenCheckedError


Do not use the following method to import local json data into the component:
const data = require('./data.json');

Use other standard approaches e.g.

this.http.get(this.dataUrl).subscribe((data: any) => {
    // Do something with json data!

No comments:

Post a Comment