jeudi 28 avril 2016

Binding an unique value from a table to ng-model of a check box

I have a table(which is populated with the data that is received from back end using ng-repeat.)Each of the rows have a check box and if the check box is selected(multiple) i want to send a request to the server to delete the rows.To do this i want to bind my check box to an unique field in my table but am unable to get the right syntax. i tried the below options that i read in SO but nothing seems to work.

  <input type="checkbox" ng-model="demo.Custid" >//this replaced the value in the table with true or false.

  <input type="checkbox" ng-model="formData.checkboxes[demo.Custid]" >//this gave me values in the below  format {"12500":true,"125001":false}

Is there anyway i can get the value of the customer id(in this case)directly bound to the ng-model uniquely?I want to get these values and send a request to the server to delete the data from the table for the corresponding customer.

 .controller('Controller1',function($scope,$rootScope,$routeParams){
 $scope.name = 'Controller1';
 $scope.params = $routeParams;
 $scope.formData = {
            checkboxes: {}

                   };
 $scope.demos = [
                 { 'Account':'abc.com',
                   'Custid': 125000,
                    },
                   {'Account':'abc.com',
                   'Custid': 125001, },
                     { 'Account':'abc.com',
                   'Custid': 125002,}
                 ]


         })

I am new to angular js and any help/pointers would be really helpful.




Aucun commentaire:

Enregistrer un commentaire