Issue
I am new to angular, I have an array data in parent component which i am passing to child component. In child component the length of array coming as zero.
Code
As a expected result count should be 5 but receiving as zero.

Could anyone help me out here, not sure what i am missing.
Solution
You're not passing the value to the child component correctly.
Currently you have:
<student-count>
[items] = "students"
</student-count>
This should be:
<student-count [items]="students"></student-count>
Properties are passed via [] and events/handlers use (). Two-way binding uses [()].
Keep in mind that @Input only invokes change detection when the reference changes. So with arrays and objects, change detection won't respond if a member of the array changes, or a property on an object changes.
You have to pass an entirely new array or object to @Input to get change detection to work as expected.
Answered By - Brandon Taylor
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.