I have a list of objects to display in a table with ngTable. My object looks like this:
obj {label:string, nestObj{nestLabel:string } }
In my controller, I want to enable sorting and filtering by the fields 'label' and 'nestObject.label'. I 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 get an error, the javascript compiler does not like the filter on nestObj.label:
Uncaugth syntexError: unexpected token.
IT works well if I do not filter and sort nestObj.label.
Is it possible to filter and sort by nested object using ngTable?
Here are the plunker that illustrate the problem.
Thanks.
source share