Google News
logo
Angular - Interview Questions
What are angular lifecycle hooks?
Angular has 8 lifecycle hooks and these are,
 
* ngOnInit() and ngOnDestroy() – called only once.
* ngAfterContentInit() and ngAfterViewInit() – Called after the projected content and view has been initialized.
* ngAfterContentChecked() and ngAfterViewChecked() – Called every time the projected content and view have been checked.
* ngOnChanges() – Called after @Input property changes. (Bounded input properties)
* ngDoCheck() – Called during all the change detection run.

All the above (onChanges, onInit, DoCheck etc..) should be imported from @angular/core.
Advertisement