在ng-repat中绑定ng-model的正确方法
Propper way to bind ng-model in ng-repat
我有这个
"List": {
"lorem": 127,
"ipson": 5.5,
"dolor": 29,
"sit": 19}
然后使用下面的ng-repeat代码创建一个带有输入字段
的表<table>
<tr ng-repeat="(item, weight in settings.list">
<th>
<input ng-model="item"></input>
</th>
<th>
<input ng-model="weight"></input>
</th>
</tr>
</table>
现在我显然希望ng-model更新父范围,但我不知道如何做到这一点
你可能想要一个这样的列表:
list : [
{
name : "lorem",
weight : 127
},
{
name : "haha",
weight : 12
}
];
然后:
<table>
<tr ng-repeat="item in settings.list">
<th>
<input ng-model="item.name"></input>
</th>
<th>
<input ng-model="item.weight"></input>
</th>
</tr>
</table>
相关文章:
- 从 Javascript 中设置 ng-model name
- Toggle Switch在包含ng model和ng repeat之后不进行切换
- 在Angularjs中,我如何使用ng repeat、ng model和ng click来动态更改内容
- 当与之关联的 ng-model 为 false 时,Angularjs 复选框值不会取消选中
- ng-model 绑定到选择标签生成的空默认值
- 对象不能在angularjs ng-model中访问
- 为什么 HTML 中的 Value 属性在与 AngularJS 中的 ng-model 一起使用时不起作用
- ng-repeat不绑定ng-model对象数组
- AngularJS:ng-model 绑定在使用 jQuery 更改时不会更新
- 选择/选项 ng-model 未绑定 ng-selected
- Angular ng-model 将数据作为数组发送到 rails-api
- 为什么 AngularJS 在使用 ng-model 时不会在文本框上设置长度属性
- AngularJS:Ng:init-如何分配Ng:model
- 在指令中使用 ng-model 和 ng-repeat
- 使用 angularjs 访问控制器中的 ng-model 数据
- 如何在 Angularjs 中为 ng-model 增加价值
- 如何在 AngularJS 中将 ng-model 值检索到控制器
- 从角度“ng-model”选择元素中选择第一个选项,带有一个按钮
- 使用 ID 更新文本区域值,而不是在 AngularJs 中使用 ng-model
- 在ng-repat中绑定ng-model的正确方法