我使用checkbox
从model
创建了多个输入ng-repeat
,当我选择其中一些时,我得到了这个:
var accounts = [AA764: true, AA324: true, AA234: false, AA553: true, AA7365: false];
但我需要在控制器中操作以下结构来调用和REST API:
var accounts = ['AA764', 'AA324', 'AA553'];
这是我获取要转换的数组的方式:
<span><a href="javascript:void(0)" ng-click="deleteAsobancariaAccountModalDialog(asobancariaAccounts)"><i class="pe-7s-trash"></i> Eliminar</a></span>
<tbody ng-repeat="account in reconcileBankAccounts">
<tr>
<td><input type="checkbox" ng-model="asobancariaAccounts[account.accountBankId]"> {{account.accountName}}</td>
<td>{{account.paymentMethodMain}}</td>
<td><i class="pe-7s-pen"></i> <a href="javascript:void(0)" ng-click="updateAsobancariaAccountModalDialog(account)">Editar</a></td>
</tr>
</tbody>
在控制器中:
$scope.deleteAsobancariaAccountModalDialog = function (asobancariaAccounts) {
console.log(asobancariaAccounts); // [AA764: true, AA324: true, 'AA234': false, 'AA553': true, 'AA7365': false]
var modalInstance = $modal.open({
templateUrl: SECURE_CONSTANTS.VIEWS + SECURE_CONSTANTS.MODALS.DELETE_ASOBANCARIA_ACCOUNTS,
size: 'md',
keyboard: true,
controller: 'asobancariaCreateController',
scope: $scope,
resolve: {
asobancariaAccount: function(){
asobancariaAccounts.action = "delete";
return asobancariaAccounts;
}
}
});
};
只有那些被选中的checkbox
,我尝试过使用javascript foreach
函数,但我无法使其正常工作。是否有任何有角度的图书馆或可能有凉亭可以帮助我?感谢。