My component has an mutable object input. When property of object changed,ngOnChanges of component is not called.It's easily understand.But the it's display changed rightly.
My component hero-card:
export class HeroCardComponent implements OnChanges , DoCheck {
@Input()
Hero: Hero;
@Input()
Title: string;
ngOnChanges(changes: SimpleChanges) {
for (const propName in changes) {
const chng = changes[propName];
const cur = JSON.stringify(chng.currentValue);
const prev = JSON.stringify(chng.previousValue);
console.log(`${propName}: currentValue = ${cur}, previousValue = ${prev}`);
}
}
}
It's template:
{{Title}}<br>
Hero title : {{Hero.title}}<br>
Hero name : {{Hero.name}}<br>
I changed hero.name in an input which has an two-way binding with hero.name.
Could Angular really checked the change?
The display changed seems it checked the change even in mutable object.Yeah , great!
But ngOnChanges is not called. It seemed that angular not checked the change. May be it only reset all of the view no matter change or not.
Who can tell me the truth?Thanks!