Created
May 28, 2020 14:40
-
-
Save AregSargsyan/fef51b4c56ca15edbf5d55ab8d6e676e to your computer and use it in GitHub Desktop.
ngZone.run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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