我有以下HTML,其中包含ng-repeat
内的复选框<table>
<tr ng-repeat="address in contactInfo.Addresses">
<td>{{address.DisplayType}}</td>
<td>{{address.AddressLine1}}</td>
<td>{{address.AddressLine2}}</td>
<td>{{address.City}}</td>
<td>{{address.State}}</td>
<td>{{address.Zip}}</td>
<td>
<input type="checkbox" ng-model="address.ClientDefault" ng-checked="{{address.ClientDefault}}" ng-click="updateAddressSelection($index, contactInfo.Addresses)" />
</td>
<td><i class="fa fa-envelope-square"></i></td>
</tr>
</table>
当我运行
的updateAddressSelection函数时$scope.updateAddressSelection = function(position, address) {
angular.forEach(address, function(address, index) {
if (position != index) {
address.ClientDefault = false;
}
});
};
它不会从使用ng-checked标记的原始复选框中删除复选框。重复的json对象看起来像这样。
{
"ID": 6,
"DisplayType": "Other",
"AddressLine1": "123 test st",
"AddressLine2": "",
"City": "madeupville",
"State": "MO",
"Zip": "63123",
"AddressType": 3,
"Linked": 0,
"ClientDefault": "true",
"HouseholdDefault": 0
}
如何在点击时删除最初标记的复选框。除了未清除默认复选框之外,这是完美的。
答案 0 :(得分:0)
请使用您运行 updateAddressSelection 方法的参数编写。