Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Angular 2+: Update @Input property when parent value changes

I have a parent and child component where the parent is passing an object to the child through the @Input decorator. The problem is the child gets the parent data only once, then after future changes to parent property that is passed to the child, the value is not being update.

like image 700
user2385716 Avatar asked Mar 13 '18 06:03

user2385716


1 Answers

Try to get the changes by ngOnChanges

use it in the child component

  ngOnChanges(changes: import("@angular/core").SimpleChanges): void {

}
like image 101
Mohammad Hassani Avatar answered Oct 05 '22 03:10

Mohammad Hassani