Skip to content

Instantly share code, notes, and snippets.

@AregSargsyan
Created May 28, 2020 14:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save AregSargsyan/fef51b4c56ca15edbf5d55ab8d6e676e to your computer and use it in GitHub Desktop.
Save AregSargsyan/fef51b4c56ca15edbf5d55ab8d6e676e to your computer and use it in GitHub Desktop.
ngZone.run
export class AppComponent implements OnInit {
constructor(private ngZone: NgZone) {}
ngOnInit() {
// New async API is not handled by Zone, so you need to
// use ngZone.run() to make the asynchronous operation in the angular zone
// and trigger change detection automatically.
this.ngZone.run(() => {
someNewAsyncAPI(() => {
// update the data of the component
});
});
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment