0

The following filter make an ng-repeat only show panos with isOutRoom true:

<tr ng-if="building.pano.length" ng-repeat="pano in panos | filter: filterByRoom">

$scope.filterByRoom = function(pano, room) {
  return pano.isOutRoom === true
}

I also want to do have another ng-repeat that only shows panos with isVirtualRoom set to true.

How to add a second argument to the filter so I can choose between isOutRoom and isVirtualRoom?

I tried this:

<tr ng-if="building.pano.length" ng-repeat="pano in panos | filter: filterByRoom: pano.isOutRoom)"

$scope.filterByRoom = function(pano, room) {
  return pano.room === true

But now nothing shows in the ng-repeat.

alexchenco
  • 53,565
  • 76
  • 241
  • 413

2 Answers2

1

You can seperate parameters using :

filter: filterByRoom : secondArg : thirdArg

Edit: looks like this post answers the question in more detail: https://stackoverflow.com/a/16227326/841804

Community
  • 1
  • 1
Chanthu
  • 1,794
  • 1
  • 15
  • 22
1

Filters may have arguments. The syntax for this is

{{ expression | filter:argument1:argument2:... }}

E.g. the markup {{ 1234 | number:2 }} formats the number 1234 with 2 decimal points using the number filter. The resulting value is 1,234.00.

docs: https://docs.angularjs.org/guide/filter

Martijn Welker
  • 5,575
  • 1
  • 16
  • 26
  • The docs show this: `{{ expression | filter:argument1:argument2:... }}` But mine looks more like `{{ expression | filter:filterName:argument1:argument2:... }}` But that doesn't work. – alexchenco Jan 13 '16 at 10:07
  • @alexchenco Could you change it to filterName:argument1:argument2 and test that ? – Martijn Welker Jan 13 '16 at 10:09