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

ngRepeat pass collection to transcluded scope #8282

Closed

Description

@SimeonC

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?

Activity

  1. caitp commented on Jul 21, 2014

    @caitp
    Contributor

    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.

  2. jeffbcross commented on Jul 21, 2014

    @jeffbcross
    Contributor

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

  3. caitp commented on Jul 21, 2014

    @caitp
    Contributor

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

  4. SimeonC commented on Jul 21, 2014

    @SimeonC
    Author

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

  5. jeffbcross commented on Jul 21, 2014

    @jeffbcross
    Contributor

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

  6. matsko commented on Jul 22, 2014

    @matsko
    Contributor

    Here's the PR: #8046

  7. matsko commented on Jul 22, 2014

    @matsko
    Contributor

    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 join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions