Each Angular component goes through a lifecycle. This is managed by the Angular itself. Angular creates a component, renders it, creates and renders its children, looks for the changes in its data-bound properties and destroys it. Angular has lifecycle hooks for each such key moment and provide a way to act accordingly when such moment happens. Directive and component have a lifecycle. For each lifecycle moment, Angular provides a lifecycle hook . The developer can hook into such moment by implementing the one or more specific lifecycle interfaces from the Angular core. Angular provide following lifecycle hooks as under: ngOnChanges ngOnInit ngDoCheck ngAfterContentInit ngAfterContentChecked ngAfterContentInit ngAfterContentChecked ngOnDestroy Sequence of execution of the lifecycle hooks During the creation of component: Constructor ngOnChanges ngOnInit ngDoCheck ngAfterContentInit ngAfterContentChecked ngAfterContentInit ngAfterContentChecked During chang...
Tips and Tricks to make your Angular life Easy and Simple