【发布时间】:2017-12-15 19:21:55
【问题描述】:
我无法让自定义双向数据绑定在 Angular 2 中工作。文档指出盒子模型中的香蕉 - [()] 只是语法糖,但在我的示例中这种方式不起作用并且更长的方法有效:
<child-component [(test)]="check">This child updates only itself</child-component>
<child-component [test]="check" (check_send)="check=$event">This child updates all</child-component>
@Output 事件不会改变盒子模型中香蕉的父值(第一行)。 由于第二行有效,我看不出我做错了什么。 这是文档的链接:https://angular.io/guide/template-syntax#two-way-binding---
这是我为展示这种行为而创建的一个 plunker:https://embed.plnkr.co/eTfkQmRfBRxeKCEpGdzh/
编辑:这是一个与可能重复的问题不同的问题,因为这个问题不会产生任何错误,而且它是一个更简单和本地化的问题,与双向绑定的格式有关。
【问题讨论】:
标签: angular