Component Lifecycle

A component instance has a lifecycle that starts when Angular instantiates the component class and renders the component view along with its child views

( From Angular Document)

OnInitngOnInitPerform component initialization, retrieve data
OnChangesngOnChangesPerform action after change to input properties
OnDestroyngOnDestroyPerform cleanup

Example

import { Component OnInit } from '@angular/core';

export class ProductListCompnent implement OnInit {

  ngOnInit(): void {
     console.log('In OnInit');
  }
}

コメント