1 / 6

Angular _ Lifecycle Hooks

Firstly, we wonu2019t be reading this blog if there is no Angularu2026,, So, Lifecycle hooks have been part of Angular since version 2 (itu2019s long right <3). Lifecycle hooks have been loyal to Angular for nearly 5 years and promises to be for life. Enough of this coming to Actual stuff.

byteridge
Download Presentation

Angular _ Lifecycle Hooks

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Byteridge Angular : Lifecycle Hooks

  2. Byteridge Introduction • Firstly, we won’t be reading this blog if there is no Angular…,, So, Lifecycle hooks have been part of Angular since version 2 (it’s long right <3). Lifecycle hooks have been loyal to Angular for nearly 5 years and promises to be for life. Enough of this coming to Actual stuff. • Directive and Component instances have a lifecycle as Angular creates, updates, and destroys them. Developers can tap into critical moments in that lifecycle by implementing one or more of the lifecycle hook interfaces in the Angular core library. Each interface has a single hook method whose name is the interface name prefixed with ng. • When an Angular project is initialized, Angular creates and presents its root components. It is designed and it produces its heirs. For the components that are loaded during application development, Angular keeps checking when data binding properties are changed and updated.

  3. Byteridge When are Lifecycle hooks called? • A component in Angular has a lifecycle, a number of different phases it goes through from birth to death. • It is interesting to notice that Angular itself oversees all the lifecycle of Angular Components and Directives, you have to understand the lifecycle with the result in mind to have the smooth progress of your application. The following information that I will share applies to both Components and Directives. • Components are the primary building block for any Angular application. • So it becomes utmost important to understand them to understand the processing steps of the lifecycle of components, then only it can be implemented in the application development using Angular.

  4. Byteridge How many Lifecycle hooks exist? Constructor: • This is invoked when Angular creates a component or directive by calling new on the class., • The constructor method is not actually an Angular 2 method. It is a predefined method in a TypeScript class which is called when the class is instantiated. ngOnChanges: • Invoked every time there is a change in one of the input properties of the component. • The ngOnChanges() method is a lifecycle hook that will trigger each time Angular sets a data-bound input property. That means that it should be used whenever we need something to happen whenever that property value changes.

  5. Byteridge CTPN ngOnInit • Invoked when given component has been initialized. This hook is only called once after the ngOnChanges. • The ngOnInit method runs after the constructor method, meaning that all of the injected dependencies will be resolved and all of the class members will be defined. ngDoCheck • Invoked when the change detector of the given component is invoked. This hook detects and acts upon every change that Angular can’t find automatically. It gets called before ngOnChanges() and ngOnInit() methods.

  6. Byteridge CONTACT US Contact:+91 40491 74522 Mail : info@byteridge.com Address: WeWork Rajapushpa Summit, Financial District, Hyderabad, Telangana Visit here for more : https://www.byteridge.com/expert-opinions/angular-lifecycle-hooks/

More Related