我正在学习使用ng-table指令的angular.js和new。我正在对我的数据进行分组,然后使用ng-table显示它们。我能够查看过滤后的数据,但我无法进行排序或过滤。有人可以帮我这个。这是plunker代码。谢谢!
http://plnkr.co/edit/x5NKwcxHhui9xBItqk3K?p=preview
我正在使用第112行的ng-table - >
{{sample.Field1}} {{sample.Field4}} {{sample.Field5}} {{sample.Field6}} {{sample.Field7}} {{sample.Field8}} {{sample.Field9}}在script.js文件中的代码
$scope.setCurrentSample = function(
options) {
$scope.homeview = false;
$scope.showdetail = false;
$scope.drilldown = true;
console.log("optionsxx = " + options.Field1);
$scope.myCurrentSample = _(
$scope.samples).chain()
.where(options).value();
var data1 = $scope.myCurrentSample;
$scope['test_ngtable'] = new ngTableParams({
page: 1, // show first page
count: 10, // count per page
filter: {
Field5: 'TRUE' // initial filter
},
sorting: {
Field1: 'asc' // initial sorting
}
}, {
total: data1.length, // length of data
getData: function($defer, params) {
console.log("total = " + data1.length);
// use build-in angular filter
var filteredData = params.filter() ?
$filter('filter')(data1, params.filter()) :
data1;
var orderedData = params.sorting() ?
$filter('orderBy')(filteredData, params.orderBy()) :
data1;
console.log("order by " + params.orderBy());
params.total(orderedData.length); // set total for recalc pagination
$defer.resolve(orderedData.slice((params.page() - 1) * params.count(), params.page() * params.count()));
}
});
};