[英]How to use checkbox filter on smart table?
如何在智能表上使用复选框过滤器? 这是我的代码,当用户单击复选框时,它显示firstName仅是“ Sam”记录。 这是我的代码:
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>
我尝试将以下代码用于过滤器,但未成功。
Just Show Sam: <input st-search="firstName" ng-model="a" type="checkbox" ng-true-value="'Sam'" ng-false-value="''" value="{{a}}">
您可以像这样ng-repeat='row in tableData | filter:a'
ng-repeat='row in tableData | filter:a'
并设置复选框“ Sam”的值,如下所示: <input st-search="firstName" ng-model="a" type="checkbox" ng-true-value="'Sam'" ng-false-value="''" value="Sam">
您更新的小提琴链接
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.