使用下面的代码(控制器和html页面),我看到表格没问题。但是过滤器不起作用。当我在过滤器中输入内容时:
- 所有数据消失(即使过滤器与某些记录匹配)
- 当我清洁过滤器时不会回来
任何想法 ?
谢谢,
angular.module('myApp').controller('customerListController', ['$scope', '$http', '$location', function ($scope, $http, $location) {
getCustomers = function () {
var url = '......';
$http({ method: 'GET', url: url })
.success(function (data, status, headers, config) {
$scope.customers = data.Customers;
})
.error(function (data, status, headers, config) {
});
};
$scope.customers = getCustomers();
}]);
<table st-table="customers" st-safe-src="rowCollection" class="table table-striped">
<thead>
<tr>
<th st-sort="FirstName">FirstName</th>
<th st-sort="LastName">LastName</th>
<th st-sort="Code">Code</th>
<th st-sort="Email">Email</th>
</tr>
<tr>
<th colspan="4"><input st-search="" class="form-control" placeholder="global search ..." type="text" /></th>
</tr>
</thead>
<tbody>
<tr ng-repeat="row in customers">
<td>{{row.FirstName}}</td>
<td>{{row.LastName}}</td>
<td>{{row.Code}}</td>
<td>{{row.Email}}</td>
</tr>
</tbody>
</table>
更新 1:我添加了下面的代码,但现在更改了。
$scope.customers = getCustomers();
$scope.rowCollection = $scope.customers;