update variable on @Input() change

Viewed 9099

I have an Input variable whose value is changed in parentComponent. On every change, I need to update a variable called currentNumber local to child component. At the moment I only initialise it in onInit method, but input changes over the life time of childComponent.ts

ChildComponent.ts

@Input() input;
...
...
ngOnInit(){
    this.currentNumber = this.data.someOtherNumber+this.input.numberIneed;;
}

I am aware of observers, but I feel like that declaring another service just for this is an overkill.

3 Answers
Related