私は次の構造を持っています。親は複数の子供と子供が目的を持つことができます。これを編集可能な表に表示する必要がありますが、目的の入力内でモデルをバインドすると、他のすべての選択された子どもの目的も更新されます。ここng-ng-repeat-startのng-repeat
は、2行のオプションから同じ子供を選択し、そしてそれは、他の行に反映されます1人の子供たちの目的を編集 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>
助けてください。
このシナリオを解決する適切な方法は何ですか?私は@ニクヒリッシュK Vのソリューションを使用しています。 $ rootIndexは分かりませんが、親には未定義のpropetyが作成され、paren [parentIndex] .undefined.childrens [index] .objectiveを使用して子どもにアクセスできます。間違いなく解決策ではなく、緊急時に使用されます。 – veshu
ネストされたng-repeatで動作しますが(2ウェイバインディング)、ng-repeat-startでのみ問題になりますか? – veshu