我是angularjs的新手 当我使用搜索功能时,只在第一页上工作,而不是在所有页面上
搜索框
<input type="text" class="form-control" data-ng-model="campId.campaign_id" placeholder="Search here...">
在我的HTML中
<table ng-table="tableParams" class="table table-striped">
<tr ng-repeat="campaign in $data| filter: campId">
//我的数据是什么 //如果我在表格中添加过滤器,那么只有它在这里起作用才能用于名称
<td data-title="'Name'" sortable="'name'" filter = "{ 'name':'text' }"> <div contenteditable="true">
{{campaign.name}}</div>
</td>
</tr>
</table>
以下是分页的js代码
campaign.controller('campaignController', ['$scope', '$filter', 'ngTableParams', '$http', function($scope, $filter, ngTableParams, $http) {
$http.get("api/test")
.success(function(response) {
$scope.feilds = response.campaigns;
var length_of_dict = Object.keys($scope.feilds).length;
var keys_list = Object.keys($scope.feilds);
var data = $scope.feilds;
$scope.tableParams = new ngTableParams({
page: 1, // show first page
count: 2 , // count per page
filter : {
campaign_id : '' // initial sorting
}
}, {
total: length_of_dict, // length of data
getData: function($defer, params) {
// use build-in angular filter
//alert(params) ;
var orderedData = params.filter() ?
$filter('filter')(data, params.filter()) : //This will be used to filter the dictionary array and return back only those resource objects that has the desired key the user is looking for.
data;
$defer.resolve(orderedData.slice((params.page() - 1) * params.count(), params.page() * params.count()));
}
});
});
}]);