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)
OnInit | ngOnInit | Perform component initialization, retrieve data |
OnChanges | ngOnChanges | Perform action after change to input properties |
OnDestroy | ngOnDestroy | Perform cleanup |
Example
import { Component OnInit } from '@angular/core'; export class ProductListCompnent implement OnInit { ngOnInit(): void { console.log('In OnInit'); } }
コメント