javascript - How can I filter items in ngRepeat from array of numbers? -


i'm struggling find way of filtering set of results in ng-repeat, based on array of numbers. numbers can represent results want see, or not see. i'm able use filter in view , filter 1 number, works, want put array there , filter array. don't care if filter in view, controller, or separate filter.

the code below filters topics forum id of 60

  <div ng-repeat="topic in topics | filter:{forum_id:60}">     forum id: {{topic.forum_id}} forum name: {{topic.forum_title}}   </div> 

i want filter array

  <div ng-repeat="topic in topics | filter:{forum_id:array_here}">     forum id: {{topic.forum_id}} forum name: {{topic.forum_title}}   </div> 

full plunk here: https://plnkr.co/edit/dcz7dv?p=preview

pass own function filter:

<div ng-repeat="topic in topics | filter:myfiltermethod(topic)">     forum id: {{topic.forum_id}} forum name: {{topic.forum_title}} </div> 

and in controller:

$scope.myfiltermethod = function() {     return function(e) {         return $scope.filterby.includes(e.forum_id);     } } 

updated plunkr


Comments

Popular posts from this blog

What is happening when Matlab is starting a "parallel pool"? -

angular - DownloadURL return null in below code -

php - Cannot override Laravel Spark authentication with own implementation -