Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

angular's @input vs viewchild for sending data from parent to child component

Tags:

angular

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?

like image 843
anonymous Avatar asked Jun 18 '17 08:06

anonymous


1 Answers

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()

like image 200
Aravind Avatar answered Oct 31 '22 15:10

Aravind