Is it possible to detect change in a variable?
I have the following:
@Input('name') name: string;
I would like to call a function whenever change is happened in this variable 'name'.
Is it possible?
I am solve this question using default Angular feature named OnChanges, very similar to OnInit.
OnChanges is not triggered if change is made outside of the views. A good explanation is here: medium.com/@isaacplmann/… From this point of view, I would say the get / set solution in blog above or by @Mathias is better, but I don't like the use of private variable.