mercredi 11 octobre 2017

Two way binding in a list of checkbox in angular JS

In the following, I retrieve a list of object from which a list of check box are created. Depending on the IsActive(Boolean) column value its either checked or unchecked.

 <div class="col-xs-12">
    <div class="col-xs-12" ng-repeat="x in Nodes" ng-model="Locations">
        <input type="checkbox" style="width:auto" ng-checked="x.IsActive"/>
        <label style="width:auto"></label>
    </div>
</div>

here is the function where I am fetching Objects in Nodes list.

 $scope.GetNodes = function () {

             var nodeUrl = baseUrl + 'api/RoleNodeAccess/GetRoleNodeAccessDetails/?roleId=' + $scope.role;

             $http({ method: 'get', url: nodeUrl }).then(function success(response) {
                 $scope.Nodes = response.data;
             }, function failed(response) {
                 console.log('Failed getting nodes.');
             })
         }

The issue here is, whenever the state of check box changes, its not reflected in Nodes list. Am I missing something.

Thanks in Advance.




Aucun commentaire:

Enregistrer un commentaire