ngOnInit

noun

say it: “EN-JEE on ih-NIT” /ˌɛn ˈdʒiː ɒn ɪˈnɪt/

The Angular lifecycle method that runs once when a component is ready, often used to load data.

What does ngOnInit do?

ngOnInit runs once, after Angular has set up the component and its inputs. It is the usual place to start loading data.

export class OrderHistory implements OnInit {
  ngOnInit() {
    this.loadOrders();
  }
}

In a sentence

  • “The product list loads its data in ngOnInit.”

Level: Apprentice · More Angular terms at this level

Updated