I am learning angular.js and new to use ng-table directive. I am grouping my data and then showing them using ng-table. I am able to view the filtered data but I am not able to do sort or filtering. Can someone please help me with this. Here is the plunker code. Thank you!
http://plnkr.co/edit/x5NKwcxHhui9xBItqk3K?p=preview
I am using ng-table from line number 112-->
{{sample.Field1}} {{sample.Field4}} {{sample.Field5}} {{sample.Field6}} {{sample.Field7}} {{sample.Field8}} {{sample.Field9}}in the script.js file the code
$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()));
}
});
};
<tr ng-repeat="sample in myCurrentSample | filter:search ">
first you need to replace with this
<tr ng-repeat="sample in $data | filter:search ">
The ngTable
directive working with $data
variable ,look example.
i tried with your plunk ,and replacing solved the problem,here working version of your plunk.