Would there be any errors or collision if using ViewChild
and Input
at the same time? Or is it recommended practice in general?
Currently h
The link you indicate is a bit old. In my opinion, the use of viewChild is usefull when we want to use a method or function of the child(*), or change his aspect. For control a variable or a FormGroup or formControl my best bet is use @Input.
Remember that, when we pass an object to a child in a Input, there are an unique object, so parent and children has the value when any change happens -in children or in parent-, e.g. if we pass a FormGroup, you can mark as touched, remove/add validators, use setValue... from parent or form children. About @Input is true that if you has a "input fixed" -you pass a variable that not change- ,as
<child greet="Hello word"></child>
You should use @Attribute in constructor, NOT input
constructor(@Attribute('greet') greet){}
(*)you can use a input with a setter, but in this case I like much more use viewChild or a variable reference