Skip to main content

Posts

Showing posts with the label AfterViewInit in Angular

AfterViewInit in Angular – Lifecycle Hook

What Is AfterViewInit in Angular? The AfterViewInit () is a lifecycle hook that is invoked when the component’s view has been fully initialized. The ngAfterViewInit() method is used to handle any additional initialization tasks. The AfterViewInit() is called once after ngAfterContentChecked. The ngAfterViewInit() is the method of AfterViewInit interface. The AfterViewInit interface code from Angular doc and its look like, interface   AfterViewInit  {    ngAfterViewInit ():  void } The ngAfterViewInit() method calls after it creates a component's child views. A callback method that is invoked immediately after Angular has completed initialization of a component's view. The ngAfterViewInit() method invoked only once when the view is instantiated. Example , @ Component ({    selector:   'my-app' ,     template:   `<h3>ngAfterViewInit() Demo</h3>` }) class   MyDe...