Skip to content

Instantly share code, notes, and snippets.

@ReeMii
Last active December 13, 2019 14:48
Show Gist options
  • Save ReeMii/7c2acaa4e1e35c324f87d690bd17fdc6 to your computer and use it in GitHub Desktop.
Save ReeMii/7c2acaa4e1e35c324f87d690bd17fdc6 to your computer and use it in GitHub Desktop.
angular lifecycle hooks #angular

In Order

  1. constructor()
  2. ngOnChanges(changes: SimpleChanges) - It is called every time the data changes.
  3. ngOnInit() - it is called only once when the component is loaded into the DOM
  4. ngDoCheck() - whenever theere is a change detection
  5. ngAfterContentInit() - is called once external content is projected into component’s view and right after the first ngDoCheck() and occurs only once.
  6. ngAfterContentChecked() - called once after ngAfterContentInit() and everytime after ngDoCheck()
  7. ngAfterViewInit() - is called once after the component’s view/ child views are loaded and right after ngAfterContentChecked() and occurs only once.
  8. ngAfterViewChecked() - called once after ngAfterViewInit() and everytime after ngDoCheck()
  9. ngOnDestroy() - is called right before the component gets destroyed and occurs only once.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment