angular lifecycle hooks 1

angular lifecycle hooks

AngularJS lifecycle hooks
Angular gives us 8 hooks to allow us to tap into the lifecycle of our components and trigger actions at specific points in the lifecycle.

1. ngOnChanges
2. ngOnInit
3. ngDoCheck
4. ngAfterContentInit
5. ngAfterContentChecked
6. ngAfterViewInit
7. ngAfterViewChecked
8. ngOnDestroy

Here is what the above code is Doing:
1. We are importing the OnInit interface from the @angular/core package.
2. We are implementing the OnInit interface.
3. We are defining a ngOnInit() method.
4. We are calling the ngOnInit() method inside the constructor.

Similar Posts