我正在尝试使用AngularJS,根据从数据库中获取的数据,以动态过滤器(位置-值如US、IN、CA等)的形式显示员工详细信息,并将其作为复选框列表显示。我已经尝试了多种方法,但都没有成功。请帮忙实现来自复选框列表的动态过滤器。
下面是我的代码示例:
<html>
<body ng-app="myapp" ng-controller="myController">
<div >Location</div>
<table>
<tbody>
<tr ng-repeat="empL in EmpResult | unique : 'Location'">
<td>
<span>
<input type="checkbox" ng-model="loc" value={{empL.Location}} />
{{empL.Location}}
</span>
</td>
</tr>
</tbody>
</table>
<table align="left" style="width: 100%" class="table">
<thead>
<tr>
<th align="left" style="width: 30%">Employee</th>
<th align="left" style="width: 20%">Address</th>
<th align="left" style="width: 15%">Location</th>
</tr>
</thead>
<tbody>
<tr ng-repeat="empN in EmpResult | filter : loc">
<td align="left" style="width: 30%">{{empN.EmpName}}</td>
<td align="left" style="width: 10%">{{empN.Address}}</td>
<td align="left" style="width: 15%">{{empN.Location}}</td>
</tr>
</tbody>
</table>
<script type="text/javascript">
var myapp = angular.module('myapp', ['ui.unique'])
.controller("myController", function ($scope, $http) {
$http({
method: 'Get',
params: { strName: $scope.strName },
url: 'Emp.asmx/GetEmpbyName'
}).then(function (response) {
$scope.EmpResult = response.data;
})
});
</script>
</body>
</html>
'ui.unique'
,因此不需要定义。然而,这个依赖项已经被弃用了,所以我的问题是为什么要使用一个被弃用的依赖项呢? - Raman Sahasi