How to use checkbox filter on smart table?? here is my code,When user click the check box,it show firstName is'Sam' record only. Here is my code:
angular.module('smarttabledemo', ['smart-table']).run(function() {
console.clear();
})
.controller('smarttabledemo', function($scope) {
$scope.data = [
{ firstName: 'Sam', lastName: 'Evans', phone: 'Not Provide', hometown: 'Anytown, ST' },
{ firstName: 'Saul', lastName: 'Evans', phone: '555-555-1234', hometown: 'Anytown, ST' },
{ firstName: 'Charlie', lastName: 'Anders', phone: '555-555-9876', hometown: 'Springfield, ST' },
{ firstName: 'Jessica', lastName: 'Cortez', phone: 'Not Provide', hometown: 'Springfield, ST' },
{ firstName: 'Amy', lastName: 'Wood', phone: '555-555-1348', hometown: 'Metroville, ST' },
]
})
<div class='container' ng-app='smarttabledemo' ng-controller='smarttabledemo'>
<h3>Minimal Angular/Smart-Table Demo</h3>
<table st-table='data' class='table'>
<thead>
<tr>
<th colspan='999'>
<input st-search class='form-control' type='search' placeholder='Search' ng-model='search' />
</th>
</tr>
<tr>
<th st-sort='firstName'>First Name</th>
<th st-sort='lastName'>Last Name</th>
<th st-sort='phone'>Phone Number</th>
<th st-sort='hometown'>Hometown</th>
</tr>
</thead>
<tbody>
<tr st-select-row='row' ng-repeat='row in data'>
<td>{{row.firstName}}</td>
<td>{{row.lastName}}</td>
<td>{{row.phone}}</td>
<td>{{row.hometown}}</td>
</tr>
</tbody>
</table>
</div>
I try to use the following code for filter, but not success.
Just Show Sam: <input st-search="firstName" ng-model="a" type="checkbox" ng-true-value="'Sam'" ng-false-value="''" value="{{a}}">
You can pass filter option in ng-repeat like this ng-repeat='row in tableData | filter:a'
ng-repeat='row in tableData | filter:a'
and set value of checkbox "Sam" like this <input st-search="firstName" ng-model="a" type="checkbox" ng-true-value="'Sam'" ng-false-value="''" value="Sam">
your updated fiddle Link
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.