There's a behavior in Angular I don't really understand. Let's say I've two components : a parent and a child. The parent component passes data to the child.
In the child component :
- When properties of the passed object are updated, the object updates both in parent and child component.
- When the object value is updated, the parent component does not update.
I don't know if I made it clear, so I made this plunker :
http://next.plnkr.co/edit/PnlotZxt3DLbAGAF?open=lib%2Fapp.ts&deferRun=1&preview
Hit "Update Salary" to update the salary property of the employee object. Hit "Update Employee" to update the employee object value.
Can someone please explain me this behavior ? I though using bracket and @Input() was for one-way data binding only and now I'm confused.
Thank you!