I have a tabel with rows with checboxes in it. When I click on a checkbox, I want the value of the ID-attribute to be pushed into the object.
I have the following HTML-code:
<tr ng-repeat="info in test">
<td>{{info.stracka}}</td>
<td>{{info.tid}}</td>
<td><input type="checkbox" id="{{info.id}}" ng-model="compare.checkbox">
</tr>
As you can see, my ng-model connected to a compare object. How do I add the value of the ID-attribute to my compare object? And the ng-model seems to only be able to bind the value of one single checkbox to a variable in the controller. How can I solve this?
Here is my controller:
as.controller('Test', function($scope, $http, $rootScope, testFactory)
{
$http.get($rootScope.appUrl + '/nao/test/test')
.success(function(data, status, headers, config) {
$scope.test = data.data;
});
$scope.form = {};
$scope.compare = {};
$scope.submitForm = function(isValid) {
if(isValid)
{
/*testFactory.testFactoryMethod(function($http) {
$scope.test = data;
});*/
$http.post($rootScope.appUrl + '/nao/test', $scope.form)
.success(function(data, status, headers, config) {
console.log(data);
$scope.test.push($scope.form);
$scope.test.push(data);
}).error(function(data, status) {
});
}
};
});
$scope.compare.checkbox
variable? – Kasyx Jul 17 '14 at 14:10