Home > Back-end >  Does Angular 11 support ngAfterViewInit() or AfterViewInit?
Does Angular 11 support ngAfterViewInit() or AfterViewInit?

Time:02-25

ngAfterViewInit(){
   `this.initializeDateSettings(.....);`
}

Is this supported by angular 11?

CodePudding user response:

Yes, ngAfterViewInit() will support in Angular 11 lifecycle. A lifecycle hook is called after Angular has fully initialized a component's view. Define a ngAfterViewInit() method to handle any additional initialization tasks.

https://angular.io/api/core/AfterViewInit

CodePudding user response:

I just want to explain this life cycle hook. I hope this will help you to understand more about this.

This is the import when we import we use "AfterViewInit";

import { AfterViewInit } from @angular/core;

And also when we implement with class name we use AfterViewInit:

export class Home implements AfterViewInit {
}

When we use as a method than we should use ngAfterViewInit().

This is the requirements of the angular.

ngAfterViewInit() {

}
  • Related