What is ngOnInit? How is it defined? 

ngOnInit is a lifecycle hook and a callback method that is run by Angular to indicate that a component has been created. It takes no parameters and returns a void type.

export class MyComponent implements OnInit {

  constructor() { }

  ngOnInit(): void {

    //….

  }

}


Comments

Leave a Reply

Your email address will not be published. Required fields are marked *