What are the different lifecycle hooks available to Components in Angular?

The below are the lifecycle hooks available in Angular. These are added by implementing the respective interface on the component.

  1. ngOnChange - before OnInit and whenever Input property changes in value
  2. ngOnInit - called once the Input properties are set, used to fetch initial data
  3. ngDoCheck - detect and act upon any changes that are by default on detected
  4. ngAfterContentInit - after loading any external entity into the component, such as a directive
  5. ngAfterContentChecked - after the content loaded is checked
  6. ngAfterViewInit - after the view is initialized
  7. ngAfterViewChecked - after the view is checked
  8. ngOnDestroy - just before the component is destroyed

Angular •  Added 7 days ago

What are the different types of Subjects available in Angular?

* A subject is a special type of Observable which shares a single execution path among the observers which results in a multicast (one to many). * Th ...

How to create Routing in Angular?

1. Import and add RouterModule to the modules in NgModule 2. Declare a routes array which contains all the routes and their endpoints and then pass t ...

How can you create a transient service in Angular?

* When you register a service into DI in Angular, the services are marked Singleton. * Alternatively to create a transient service (a new instance o ...

What is the difference between parseInt() and number()?

parseInt() and Number() are both used to convert a string into a number. * parseInt() parses the value of the string and converts to number till th ...

How can you work with cookies in Angular?

To work with Cookies, we can make use of the CookieService which is a part of the ngx-cookie-service module. * Install: `npm install --save ngx-coo ...

We use cookies to provide you with a great user experience, analyze traffic and serve targeted promotions.   Learn More   Accept