简体   繁体   English

按值或引用绑定Angular 2模板数据

[英]Angular 2 template data binding by value or reference

If a parent component passing an object to a child component 如果父组件将对象传递给子组件

<child-component [someValue]="someObject"></child-component>

If the child component modify the someObject , will this change be reflected in the parent component? 如果子组件修改someObject ,此更改是否会反映在父组件中?

  • By value for primitive types number , string , boolean 按值表示原始类型numberstringboolean
  • By reference of objects when an object is passed changes done by the receiver will take effect on the sender as well. 通过引用对象,当对象通过时,接收者所做的更改也将对发送者生效。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM