6

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?

2
  • I hope that view child is best one instead of input.check with Behavioural subject is updated all child components . Commented 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. Commented Dec 19, 2018 at 17:49

1 Answer 1

5

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

Sign up to request clarification or add additional context in comments.

8 Comments

1 way data binding sets the value to the object.
What do you mean by 1 way data binding sets the value to the object?
you have any prior knowledge about angular?
I know what is one way binding, why do you mention that here in the comment
Why not use input setter over viewChild?
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.