-1
我也有一个AngularJS控制器,它看起来是这样的:筛选表使用AngularJS
app.controller('StudentController', ['$scope', function($scope) {
$scope.filter: {
hobby: {
football: false,
tennis: false,
soccer: false
}
}
$scope.students: [
{
name: John,
hobby: [soccer, football, tennis]
},
{
name: James,
hobby: [soccer, tennis]
}
]
]);
在HTML方面,我有一些复选框和学生的表格显示表:
<input type="checkbox" ng-model="filter.hobby.soccer"><label>Soccer</label>
<input type="checkbox" ng-model="filter.hobby.tennis"><label>Tennis</label>
<input type="checkbox" ng-model="filter.hobby.football"><label>Football</label>
<table>
<thead>
<tr>
<th>Name</th>
<th>Hobbies</th>
</tr>
</thead>
<tbody ng-repeat="student in students">
<tr ng-hide="rotation.hideRotation">
<td>{{ student.name }}</td>
<td>{{ student.hobby.join(', ') }}</td>
</tr>
</tbody>
</table>
我想知道如何使用AngularJS过滤表格。例如,当我点击复选框来过滤足球时,只有James会出现。
请考虑提供[最小,完整,可验证示例](http://stackoverflow.com/help/mcve)。这样,SO上的志愿者更有可能帮助你。 – lealceldeiro
我同意@lealceldeiro +您的json不正确。 –