I want to put the values of dynamic checkboxes (not boolean true and false) in the form of array using \'ng-model\' in a similar way as is done using \'name\' attribute. This ar
You have to bind each input to a different value. Currently all of them are bound to the field operations
in the scope via ng-model="operations"
.
I suggest you create an array operations
in your controller like this:
$scope.operations = new Array($scope.operations_publish.length);
Then you can bind the checkboxes to the respective index in this array:
{{operation}}
This will give you an array with true
at all checked indexes. If you then want the selected values as strings in an array, you can collect them like this:
function getSelected() {
return $scope.operations_publish.filter(function (x,i) {
return $scope.operations[i]
});
}
Check this fiddle for the complete code.