1

Okay so i wasnt quite sure what to call this question.

But i have the following ng-repeat:

ng-repeat="module in modules |filter:{ module_type_id: selectedItem.id } |filter:search:strict"

This is iterating through objects that looks like this:

{id: 1, name: 'Hello', module_type_id: 5}

Now i have 12 module types so any of these objects have a module_type_id between 1 and 12.

When i click one of the categories thereby selecting a type the variable selectedItem is set to that value. (which then sorts the list)

This works however there is an odd bug.

if i choose the category that has id 1 then elements with id 1, 10, 11,12

my guess is that the filter is taking part of the value and therefor only shows results that contains the value. and since 1,10,11,12 all contain the value 1 then these results are shown.

So how can i make sure that it only shows the result that exactly match the value?

3
  • can you please make a fiddle of it. I want to see the whole code, working. Commented Jul 6, 2015 at 11:28
  • I think strict is not working properly. Commented Jul 6, 2015 at 11:31
  • 1
    alternatively you can user 'where' github.com/a8m/angular-filter#where Commented Jul 6, 2015 at 11:33

1 Answer 1

7

Filter takes another parameter that makes it strict, you're using it for your second part...

ng-repeat="module in modules |filter:{ module_type_id: selectedItem.id } : true |filter:search:strict"
Sign up to request clarification or add additional context in comments.

1 Comment

But, how are you supposed to fix negation to be strict? '!2' will negate 2, 22, 222, 202, 201, etc. Setting it to strict negates all records.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.