Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.
Sign upng-repeat object expressions does not support passing the key or value into any filter #10333
Comments
|
@wesleycho, the collection part of the microsyntax is its own expression which is evaluated separately from (and prior to) the "item" portion of the microsyntax --- so the collection expression doesn't know about the "k" or "v" |
|
I'm not sure this is really fixable since it would mean evaluating that filter for each item in the collection, which would be a perf killer (and it wouldn't really make sense in the first place) |
|
Maybe a strong recommendation to not use objects and use arrays in the docs would be worthwhile then? |
|
It would be the same case in an array, you wouldn't be able to use the array index in the filter expression either. But yes, a recommendation to use arrays would be good |
|
I'm going to close this because it seems pretty invalid, but it wouldn't hurt to add a line explaining that these expressions are separate, and also add a line encouraging the use of Arrays |
Here I created a custom filter that is using ng-repeat to iterate over an object: http://plnkr.co/edit/D3EnGBxxLOjaFhZbJDT1?p=preview
Notice in the console that the key and value are outputted as undefined - I believe ng-repeat should support using the key and value in the filter part of the expression after the first portion.