Search code examples
angularjsangular-filters

Angular.js ng-repeat :filter by numeric field


I am trying to apply a filter to a numeric field as follows:

ng-repeat="venue in venues | filter:{ regionId: regionId }"

however, if for example, the regionId is 2, it will return venues for regionId's 2, 12, 23 etc.

Can anyone please advise the best way to resolve this?


Solution

  • The documentation says:

    Usage

    In HTML Template Binding

    {{ filter_expression | filter : expression : comparator}}
    

    [...]

    comparator: function(actual, expected) | true | undefined

    Comparator which is used in determining if the expected value (from the filter expression) and actual value (from the object in the array) should be considered a match.

    Can be one of:

    [...]

    true: A shorthand for function(actual, expected) { return angular.equals(expected, actual)}. this is essentially strict comparison of expected and actual.