0

I am working on a project where there is template which i am loading through a bootstrap modal in asp.net MVC in that modal there is a table which i am loading dynamically. There are checkboxes beside each record and on selection of every checkbox that data is getting selected. Now i want to add a parent checkbox on click of which i want to check all checkboxes from that table. I have written following code but not able to achieve the functionality. `

<table class="table table-condensed table-bordered table-hover left" style="width:100%;margin:0px;" <thead> <tr> <th> <input type="checkbox" style="margin: 3px 0; ng-model="selectAll" ng-click="checkAll()"> </th> <th>NAME</th> <th>CITY</th> </tr> </thead> <tr ng-repeat="clientData in Clients> <td> <input type="checkbox" style="margin: 3px 0;" ng-model="clientData.IsSelectedClients" ng-change="checkClients(clientData.IsSelectedClients); IsAllSelectedClient=false;"/> </td> <td>{{clientData.Name}}</td> <td>{{agentData.City}}</td> </tr> </table>` 

Angular js code is below

 $scope.checkAll = function() { angular.forEach($scope.Clients, function(client) { client.IsSelectedClients= $scope.selectAll; }); }; 

I am not able to find out why it is not working can anybody help me to get it working Thanks in advance

5
  • Did you tried ng-checked?CommentedJun 13, 2021 at 16:33
  • @AmitGupta no i've not tried
    – shreyas35
    CommentedJun 13, 2021 at 16:39
  • Try adding attribute ng-checked="clientData.IsSelectedClients"CommentedJun 13, 2021 at 17:01
  • @AmitGupta i've tried not working
    – shreyas35
    CommentedJun 14, 2021 at 3:21
  • Then please confirm IsSelectedClients attribute of $scope.Clients have true value when you click on select all? Also, check what is the value of $scope.selectAll.CommentedJun 14, 2021 at 6:33

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.