0
@Input() UpItem: Item ;

On catching something in UpItem I want to execute a function when some property is passed from parent to child.

Stephen Rauch
  • 47,830
  • 31
  • 106
  • 135
shubhamsjmit
  • 81
  • 2
  • 6

1 Answers1

0

Using a getter/setter is probably the best way

private _upItem:Item
@Input() set UpItem(value:Item) {
  this._upItem = value;
  this.doSomething();
}
get UpItem():Item {
  return this._upItem;
}

ngOnInit might be more convenient if you want to call the same code when one or more of several different inputs change

Günter Zöchbauer
  • 623,577
  • 216
  • 2,003
  • 1,567