I have multiple input checkbox
s created from a model
with angular using ng-repeat
, when I select some of them I get this:
var accounts = [AA764: true, AA324: true, AA234: false, AA553: true, AA7365: false];
But I need following structure to manipulate in controller that calls and REST API:
var accounts = ['AA764', 'AA324', 'AA553'];
This is the way I obtain the array to be converted:
<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>
In the Controller:
$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;
}
}
});
};
Just those checkbox
that are selected, I have tried with the javascript foreach
function but I cannot make it work. Is there any library for angular or maybe with bower that can help me? Thanks.
Aucun commentaire:
Enregistrer un commentaire