1

This is my repeat filter.

<div ng-repeat="f in fs | filter: v.list[vId].make.makerId | limitTo: 12">

make.makerId is an integer value equal to the vId in this sample list.

[{ vId: 28, qty: 21.07, fDate: "17/07/2013", price: 0.00 },
 { vId: 2,  qty: 24.26, fDate: "15/06/2013", price: 0.00 },
 { vId: 2,  qty: 22.16, fDate: "22/05/2013", price: 0.00 },
 { vId: 28, qty: 22.16, fDate: "28/05/2013", price: 0.00 },
 { vId: 72, qty: 22.16, fDate: "29/05/2013", price: 0.00 },
 { vId: 72, qty: 30.16, fDate: "30/05/2013", price: 0.00 },
 { vId: 28, qty: 25.98, fDate: "04/05/2013", price: 0.00 }]

When vId = 28, I get:

 { vId: 28, qty: 21.07, fDate: "17/07/2013", price: 0.00 },
 { vId: 28, qty: 22.16, fDate: "28/05/2013", price: 0.00 },
 { vId: 28, qty: 25.98, fDate: "04/05/2013", price: 0.00 }

When vId = 72, I get:

 { vId: 72, qty: 22.16, fDate: "29/05/2013", price: 0.00 },
 { vId: 72, qty: 30.16, fDate: "30/05/2013", price: 0.00 }

All cool so far, but when vId = 2, I get the whole list. Every instance of a 2 seems to be extracted, does anyone know how to fix this?

Thanx

Steve

1
  • 1
    this is the default behavior of the filter, it will search for every occurence of the string "2", so "2", "24.26" etc.... If you need something more specific, you can create your own filter by following the explanations given in the docs docs.angularjs.org/guide/… =) Commented Aug 15, 2013 at 11:02

1 Answer 1

3

In 1.2RC1 you can pass and additional true argument indicating that you would like to do strict comparison:

<div ng-repeat="f in fs | filter: v.list[vId].make.makerId:true | limitTo: 12">

Docs: http://docs.angularjs.org/api/ng.filter:filter

In older version of AngularJS you can write a custom filter.

Sign up to request clarification or add additional context in comments.

1 Comment

Thanx guys for your help, I have fixed the problem by making vId more unique by concatenating the id's of each table with the array index.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.