What are the ways to trigger change detection in Angular?

Posted by Jessica Taylor | Updated on

You can inject either ApplicationRef or NgZone, or ChangeDetectorRef into your component and apply below specific methods to trigger change detection in Angular. i.e, There are 3 possible ways,

  1. ApplicationRef.tick(): Invoke this method to explicitly process change detection and its side-effects. It check the full component tree.
  2. NgZone.run(callback): It evaluate the callback function inside the Angular zone.
  3. ChangeDetectorRef.detectChanges(): It detects only the components and it’s children.

If you like this question & answer and want to contribute, then write your question & answer and email to freewebmentor[@]gmail.com. Your question and answer will appear on FreeWebMentor.com and help other developers.

Related Questions & Answers