Raed Khalaf
Raed Khalaf

Reputation: 2065

When does Angular trigger ngAfterContentChecked?

According to the docs the AfterContentChecked lifecycle hook is triggered:

after Angular checks the content projected into the component

What does "Angular checks" in the documentation mean, exactly?

Upvotes: 9

Views: 15771

Answers (1)

seidme
seidme

Reputation: 13058

AfterContentChecked, component-only hook, is called after Angular checks the content projected into the component (it's data-bound properties).

When does Angular check the projected content?

  • Initially, after the AfterContentInit hook finishes.
  • Every time the change detection is run (application state change).

What causes the application state change?

  • Events - click, submit, …
  • Ajax calls - fetching data from a remote server
  • Timers - setTimeout, setInterval

See also: Angular change detection explained.

Upvotes: 16

Related Questions