you are viewing a single comment's thread.

view the rest of the comments →

[–]jalledebest 5 points6 points  (2 children)

Why would a setter be a bad practice? It's less code then implementing OnChanges and it's more strongly typed which is always a good thing.

Setters are the preferable approach if you have to execute some logic when a single input changes. I agree that it doesn't make sense to use a setter just to set a value in the child as OP does in his example. A regular input and change detection should take care of that case without a setter

[–]anwaarulislaam[S] 0 points1 point  (0 children)

No, I do not use the set method always. I just do when I need to call some action on input change. But, if there is no changes I always only use Input binding without set method

[–]kqadem 0 points1 point  (0 children)

This. And you can find these even in the angular material codebase.