Ng模型导致两个ng-repeat的问题。单击一行中的一个单选按钮,影响其他行,具有相同的ng-model值。
<table class="data-table -dark-header">
<tr>
<th>User Name</th>
<th>Read Only</th>
<th>Read Write</th>
<th>Admin</th>
<th>Super Admin</th>
<tr ng-repeat="user in wrapper_User track by user.id">
<td>{{user.firstName}} {{user.lastName}}
<td ng-repeat="groupsWithinCompany in wrapper_Group | orderBy:'id'">
<div>
<label class="radio-label">
<span class="custom-radio">
<input type="radio" name="{{user.id}}" ng-value="groupsWithinCompany.id" ng-model="user.group.id" />
</span>
</label>
</div>
</td>
</tr>
答案 0 :(得分:0)
假设问题出在您的数据结构中。
以下示例有效:
$scope.wrapper_User = [
{id:1, firstName: "firstName1", lastName: "lastName1", group:{id:10}},
{id:2, firstName: "firstName2", lastName: "lastName2", group:{id:20}},
{id:3, firstName: "firstName3", lastName: "lastName3", group:{id:30}},
{id:4, firstName: "firstName4", lastName: "lastName4", group:{id:40}}
];
$scope.wrapper_Group = [
{id:10},
{id:20},
{id:30},
{id:40}
];
确保组ID匹配