0

I am trying to filter the ng-table data with select drop down, the issue is select dropdown the values are not populating and ofcos filtering doesn't work, i am using ng-table 2.1.0 version. i tried changing the $scope.names object to hardcoded object i.e., $scope.names=[{title:'Moroni'},{title:'Enos'},{title:'Jacob'}]; then values are populating in select dropdown i am assuming there must be property 'title' for every object, but still filtering doesn't work either, is there anything missing here? plunker Here

Any help is much appreciated.

Praveen
  • 347
  • 1
  • 3
  • 20

1 Answers1

1

As I can see from the expression in ngOptions attribute:

ng-options="data.id as data.title for data in $selectData"

The format of the option should be {id: ..., title: ...}. So I think you can change your angular.forEach block with something like this:

  var titles = data.map(function(obj) { return obj.title; });
  $scope.names = titles.filter(function(title, i) { return titles.indexOf(title) === i; })
                       .map(function(title) { return {title: title, id: title}; });

This is not the fastest method to generate this array (added this just to illustrate the structure). More performant ways to do this could be found here.

Working fiddle.

Stanislav Kvitash
  • 4,614
  • 18
  • 29
  • How did i miss to check in DOM for the ngOptions format, thank you very much for pointing it out. – Praveen Aug 23 '17 at 18:40