Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ng-repeat object expressions does not support passing the key or value into any filter #10333

Closed
wesleycho opened this issue Dec 5, 2014 · 5 comments

Comments

@wesleycho
Copy link
Contributor

@wesleycho wesleycho commented Dec 5, 2014

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.

@caitp
Copy link
Contributor

@caitp caitp commented Dec 5, 2014

@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"

@caitp
Copy link
Contributor

@caitp caitp commented Dec 5, 2014

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)

@wesleycho
Copy link
Contributor Author

@wesleycho wesleycho commented Dec 5, 2014

Maybe a strong recommendation to not use objects and use arrays in the docs would be worthwhile then?

@caitp
Copy link
Contributor

@caitp caitp commented Dec 5, 2014

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

@caitp
Copy link
Contributor

@caitp caitp commented Dec 5, 2014

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

@caitp caitp closed this Dec 5, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants
You can’t perform that action at this time.