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.

Improve the new "as" feature of ngRepeat to include the status of the iteration #8398

Open
@jnizet

Description

@jnizet

It would be really cool if, in addition to having the possibility to reference the filtered collection using ng-repeat="item in items | filter:x as results (introduced in e0adb9c), the results variable had, inside the ng-repeat, all the attributes set by ng-repeat on the scope ($index, $first, $last, etc.).

This would allow for much cleaner code when nesting ng-repeats. For example:

    <tr ng-repeat="row in rows">
        <td ng-repeat="col in row.columns">
            {{ $parent.$index }}.{{ $index }} - {{ col.value }}
        </td>
    </tr>

could be replaced with the more readable, and safer in case of directives defining their own scopes:

    <tr ng-repeat="row in rows as rowItems">
        <td ng-repeat="col in row.columns as colItems">
            {{ rowItems.$index }}.{{ colItems.$index }} - {{ col.value }}
        </td>
    </tr>

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions