Post(s) tagged OnChanges

Angular detect child component Input() changes using ngOnChanges

The following method is used to detect child component Input() changes in Angular using ngOnChanges()

import { Component, Input, OnChanges, SimpleChanges, ChangeDetectionStrategy } from '@angular/core';
import { User } from './user.model';

export class SelectedUserComponent implements OnChanges {
    @Input() user: User;

    ngOnChanges(changes: SimpleChanges) {
        console.log(changes);
    }
}


19 Views Posted on February 19, 2022
SPONSORS