2

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">{{x.NodeName}}</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.

1 Answer 1

1

It seems that you should use ng-model within your checkbox something like this:

<div class="col-xs-12">
    <div class="col-xs-12" ng-repeat="(i, x) in Nodes track by $index" >
        <input type="checkbox" style="width:auto" ng-model="Nodes[i].IsActive" ng-checked="x.IsActive"/>
        <label style="width:auto">{{x.NodeName}}</label>
    </div>`enter code here`
</div>
Sign up to request clarification or add additional context in comments.

2 Comments

still not working, Nodes List remains the same as it is.
@Skye I changed my answer a little bit and now it works. I tested it.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.