我有以下结构父类可以有多个孩子和孩子会有目的。我需要在可编辑表格中显示此内容,但是当我在输入目标中绑定模型时,它会更新所有其他选择的孩子的目标。ng模型ng-repeat-ng中的ng-repeat
这里是 code
从两个行的选项中选择相同的儿童,并对其进行编辑将在其他行的反映,以及一个儿童的目标。
<tbody>
<tr ng-repeat-start="parent in records" ng-class-even="'striped'">
<!--KPI-->
<td><strong>{{parent.name}}</strong></td>
<!-- controls -->
<td tool-tips class="inputs">
<select
ng-model="parent.childrens"
ng-options="item as item.name for item in controlTypes"
multiple='multiple'>
</select>
</td>
<!-- Controls objective-->
<td colspan="1"/>
</td>
</tr>
<tr ng-if="parent.childrens.length>0"
ng-repeat="child in parent.childrens">
<td name="process" colspan="2" style="word-wrap:break-all;" align="right">{{child.name}}
</td>
<!-- Controls objective-->
<td>
<input type="text" class="ultra-short" ng-model="child.objective"
maxlength="200"/>
</td>
</tr>
<tr ng-repeat-end></tr>
</tbody>
请任何帮助。
解决这种情况的正确方法是什么?我已经使用@Nikhilish K V解决方案。不知道什么是$ rootIndex,但是它在父类中创建了一个未定义的属性,我可以使用paren [parentIndex] .undefined.childrens [index] .objective来访问子节点。绝对不是解决方案,而是紧急时刻使用。 – veshu
虽然它(双向绑定)与嵌套的ng-repeat一起使用,但是它只是ng-repeat-start的问题吗? – veshu