https://www.towfeek.se/wp-content/uploads/2015/12/ng2aspnet5auth.png 219 863 Ajden Towfeek https://www.towfeek.se/wp-content/uploads/2013/04/ts_logo1.png Ajden Towfeek2016-03-13 22:02:582023-02-17 00:10:38Angular 2 Lifecycle Hooks
Angular 2 Lifecycle Hooks
New screencast on Angular 2 beta 9, covering Lifecycle Hooks, get the code at https://github.com/ajtowf/ng2_play.
The Lifecycle Hooks
Directive and component instances have a lifecycle as Angular creates, updates, and destroys them. Here’s the complete lifecycle hook interface inventory, all of them available in the angular2/core library and called in the provided order.
- OnChanges: Calls ngOnChanges – called when an input or output binding value changes
- OnInit: Calls ngOnInit – after the first ngOnChanges
- DoCheck: Calls ngDoCheck – developer’s custom change detection
- AfterContentInit: Calls ngAfterContentInit – after component content initialized
- AfterContentChecked: Calls ngAfterContentChecked – after every check of component content
- AfterViewInit: Calls ngAfterViewInit – after component’s view(s) are initialized
- AfterViewChecked: Calls ngAfterViewChecked – after every check of a component’s view(s)
- OnDestroy: Calls ngOnDestroy – just before the directive is destroyed.
To learn more about lifecycle hooks, check out the official documentation here.
Until next time, have a nice day folks!