How to select only filtered table data in angularjs? -


this code:

<div>     <input type="search" class="form-control" placeholder="search  student" ng-  model="stdsearch" /> </div> <table class="table" >     <thead>         <tr>             <th><input type="checkbox" ng-model="master"></th>             <th>admission no</th>             <th>student name</th>             <th></th>         </tr>     </thead>     <tbody>         <tr ng-repeat="student in classstudents | filter:stdsearch">             <td><input id="checkslave" type="checkbox" ng-checked="master" ng-model="student.isselected" aria-label="slave input"></td>             <td>{{student.admission_no}}</td>             <td>{{student.first_name}}&nbsp;{{student.middlename}}&nbsp;{{student.last_name}}</td>         </tr>     </tbody> </table> 

here query : want check filtered rows in table when check master checkbox(th).but here selected rows of table when remove search text in search box. pls suggest me. 10q.

here have tried :

the plunker here

i have created sample data per html.

use 'last1' search value. idea.

$scope.classstudents = [{admission_no :1,first_name:'first1' ,middlename: 'middle1',last_name:'last1'},         {admission_no :1,first_name:'first2' ,middlename: 'middle1',last_name:'last1'},         {admission_no :1,first_name:'first3' ,middlename: 'middle2',last_name:'last2'},         {admission_no :1,first_name:'first4' ,middlename: 'middle3',last_name:'last1'}         ];   $scope.checkuncheck = function(mastercheck){                angular.foreach(  $scope.classstudents,function(value,key){                  if(mastercheck && !$scope.stdsearch){                    value.master = true;                 }else{                 value.master = false;          }          })              }  filter('customfilter',function(){      return function(input,mastercheck,stdsearch){           angular.foreach(input,function(value,key){          if(stdsearch){                 if(mastercheck){                     value.master = true;                 }else{                 value.master = false;                 }          }          })         return input;     }   })   <body ng-controller="testctrl">     <input type="text" ng-model="stdsearch">     <table class="table" >             <thead>             <tr>             <th><input type="checkbox" ng-model="master" ng-change = "checkuncheck(master) "></th>             <th>admission no</th>             <th>student name</th>             <th></th>             </tr>             </thead>             <tbody>             <tr ng-repeat="student in classstudents |filter : stdsearch| customfilter : master : stdsearch">             <td><input id="checkslave" type="checkbox" ng-checked="student.master" ng-model="student.isselected" aria-label="slave input"></td>             <td>{{student.admission_no}}</td>             <td>{{student.first_name}}&nbsp;{{student.middlename}}&nbsp;{{student.last_name}}</td>             </tr>             </tbody>             </table>   </body> 

please let me know if there error.


Comments

Popular posts from this blog

python - No exponential form of the z-axis in matplotlib-3D-plots -

php - Best Light server (Linux + Web server + Database) for Raspberry Pi -

c# - "Newtonsoft.Json.JsonSerializationException unable to find constructor to use for types" error when deserializing class -