Basic | Complete | Custom | inheritance

Inherits Directive

import { Component } from "@angular/core"
 
@Component()
export class UserProfile {}

Life Cycles

https://angular.dev/guide/components/lifecycle#summary

PhaseMethodSummary
CreationconstructorStandard JavaScript class constructor . Runs when Angular instantiates the component.
Change DetectionngOnInitRuns once after Angular has initialized all the component’s inputs.
ngOnChangesRuns every time the component’s inputs have changed.
ngDoCheckRuns every time this component is checked for changes.
ngAfterContentInitRuns once after the component’s content has been initialized.
ngAfterContentCheckedRuns every time this component content has been checked for changes.
ngAfterViewInitRuns once after the component’s view has been initialized.
ngAfterViewCheckedRuns every time the component’s view has been checked for changes.
RenderingafterNextRenderRuns once the next time that all components have been rendered to the DOM.
afterEveryRenderRuns every time all components have been rendered to the DOM.
DestructionngOnDestroyRuns once before the component is destroyed.
graph TD
  subgraph Creation
    A1[constructor]
  end

  subgraph Change_Detection
    B2[ngOnInit]
    B1[ngOnChanges]
    B3[ngDoCheck]
  end

  subgraph Content_Init
    C1[ngAfterContentInit]
    C2[ngAfterContentChecked]
  end

  subgraph View_Init
    D1[ngAfterViewInit]
    D2[ngAfterViewChecked]
  end

  subgraph Rendering
    E1[afterNextRender]
    E2[afterEveryRender]
  end

  subgraph Destruction
    F1[ngOnDestroy]
  end

  A1 --> B1 --> B2 --> B3 --> C1 --> C2 --> D1 --> D2 --> E1 --> E2 --> F1