I have implemented a same component more than once in one of my forms. I have to send data from parent to child components. I know that it can be achieved with @input or with viewchild. what is the performance issue of using one over the other? when should i use viewchild or input?
-
I hope that view child is best one instead of input.check with Behavioural subject is updated all child components .Arun Kumar– Arun Kumar2018-12-18 01:42:25 +00:00Commented Dec 18, 2018 at 1:42
-
Can anyone explain how internally in angular it makes difference in using @I/O vs viewChild. Else usecases or scenarios will be helpful to understand when its best to use what.crazyCoder– crazyCoder2018-12-19 17:49:02 +00:00Commented Dec 19, 2018 at 17:49
Add a comment
|
1 Answer
When you are using @Input(), for every change the ngOnChanges() will be called and causes more noise.
Using ViewChild() will not create any such noise. So, prefer using Viewchild over @Input()
8 Comments
Aravind
1 way data binding sets the value to the object.anonymous
What do you mean by 1 way data binding sets the value to the object?
Aravind
you have any prior knowledge about
angular?anonymous
I know what is one way binding, why do you mention that here in the comment
|