I have a list of objects to display on a table with ngTable. My object looks like :
obj {label:string,
nestObj{nestLabel:string
}
}
In my controller I want to allow sorting and filtering on fields 'label' and 'nestObject.label'. I have tried this:
$scope.tableParams = new ngTableParams({
page: 1, // show first page
count: 10,
filter: {
label='',
nestObj.label=''
},
sorting: {
label: 'asc',
nestObj.label: 'asc'
}
}, {
total: data.length, // length of data
getData: function($defer, params) {
// use build-in angular filter
var filteredData = params.filter() ?
$filter('filter')(data, params.filter()) :
data;
var orderedData = params.sorting() ?
$filter('orderBy')(filteredData, params.orderBy()) :
data;
params.total(orderedData.length); // set total for recalc pagination
$defer.resolve(orderedData.slice((params.page() - 1) * params.count(), params.page() * params.count()));
}
});
But I m getting an error, the javascript compiler doesn't like the filter on nestObj.label :
Uncaugth syntexError : unexpected token .
IT works well if I don't filter and sort on nestObj.label.
Is it possible to filter and sort on nested object with ngTable?
Here is the plunker that illustrate the problem.
Thank you.