Angular Lifecycle methods
Lifecycle hooks are methods called from the creation of a component or a directive to its destruction. For directives, the only lifecycle hooks that can be called include:
For components, the above lifecycle methods can be called together with:
N.B:
The constructor is NOT a lifecycle hook. It is however always called first always when the components are constructed. The major use of a constructor is to inject dependencies that are going to be used by the class.
The lifecycle methods are called in the order below:
ngOnChanges
ngOnInit
领英推荐
ngDoCheck
ngAfterContentInit
ngAfterContentChecked
ngAfterViewInIt
ngAfterViewChecked
ngOnDestroy
Will be further looking at implementation in another article. I hope this intro was simple enough and concise