Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

ngRepeat pass collection to transcluded scope #8282

Closed
SimeonC opened this issue Jul 21, 2014 · 7 comments
Closed

ngRepeat pass collection to transcluded scope #8282

SimeonC opened this issue Jul 21, 2014 · 7 comments

Comments

@SimeonC
Copy link

SimeonC commented Jul 21, 2014

In the case of filtered ng-repeats (ng-repeat="type in types | filter: search") it would be really useful to add something like $collection to the transcluded scope at line L276.

Then we could easily access the filtered collection in our ng-clicks and ng-class functions like we access $index.

I imagine it would be changed like the following which wouldn't incur much overhead as it is just passing an object reference:

var updateScope = function(scope, index, collection) {
  scope.$collection = collection;
  ...
};

// then at line 364 and 377
updateScope(block.scope, index, collection);

I could probably run up a PR at some point if this is acceptable?

@caitp
Copy link
Contributor

caitp commented Jul 21, 2014

Something like this has been discussed quite a bit during the meeting today, I can't remember which syntax we decided on, but I believe we'll be adding an alias to the processed (or not) collection with an arbitrary name.

The meeting notes should have details soon.

@jeffbcross
Copy link
Contributor

I believe we landed on:
item in items | filter:'foo' as results track by $index

@caitp
Copy link
Contributor

caitp commented Jul 21, 2014

was there ever an issue # opened about that? it would be good to attach this issue to it

@SimeonC
Copy link
Author

SimeonC commented Jul 21, 2014

Cool, look forward to using it. Thanks for the quick reply.

@jeffbcross
Copy link
Contributor

Not sure if it's documented, but I think @matsko is the one working on it

@matsko
Copy link
Contributor

matsko commented Jul 22, 2014

Here's the PR: #8046

@matsko matsko closed this as completed in e0adb9c Jul 22, 2014
@matsko
Copy link
Contributor

matsko commented Jul 22, 2014

Merged. The feature is now in master as:

<!-- `results` can be called anything -->
<div ng-repeat="item in items | filter:x as results">...<div>

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants