javascript - ng-repeat 破坏指令模型绑定(bind)

标签 javascript angularjs

<input-directive model="config.shared.product.whatevers[0]"></input-directive> 

<!-- above works, below doesn't bind properly -->

<td ng-repeat="whatever in config.shared.product.whatevers track by $index">
   <input-directive model="whatever"></input-directive>
</td>

基本上,当模型位于 ng-repeat 内时,模型不会从这个完全工作的指令中更新。它可以读取该值,但当我更改输入的值时不会更新。如果您需要更多代码,请告诉我!

最佳答案

找到了解决方案。我正在使用基元。

我的目标: { 香蕉:[1,2,3,4,5] }

但是,要在 ng-repeat 中使用它,请执行以下操作: { Bananas: [ { value:1 }, { value:2 }... ] } 并引用该值。我确信有一种更干净的方法可以做到这一点。

关于javascript - ng-repeat 破坏指令模型绑定(bind),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37119378/

相关文章:

javascript - 检查用户名和电子邮件是否存在后如何禁用提交按钮

javascript - 在 WordPress 主题中插入 google map api key 的位置

javascript - AngularJS Rest服务返回数据,但未显示在页面上

javascript - Angular ng-click 负载 Controller

javascript - 如何在angularjs中的两个应用程序之间共享数组

javascript - AngularJS 上带有复选框的 bool 过滤器

javascript - 如何在 react 中从另一个组件调用组件引用?

javascript - 在另一个选择实例中选择时禁用选择选项值

javascript - 闭包会终身保留js代码吗?

css - Bootstrap 导航栏下拉菜单在 iphone 上不起作用