8000 Simple @repeat(n) needed for control flow · Issue #61292 · angular/angular · GitHub
[go: up one dir, main page]

Skip to content
Simple @repeat(n) needed for control flow #61292
Open
@kshetline

Description

@kshetline

Which @angular/* package(s) are relevant/related to the feature request?

core

Description

Sometimes all that's needed from a @for loop is repeating something a given number of times.

Using @for as it is (or even the old *ngFor syntax), when all that's needed is a simple n-times repeat, requires creating a dummy array with n elements and additionally specifying both a loop variable and a tracking variable, even when they'll be ignored. For example:

Image

It would be much better if you could replace this with something simpler like this, something that doesn't cause a warning for an unused variable:

@repeat (8) {<div class="decorative-item"></div>}

Proposed solution

Some new syntax such as:

@repeat (integer-valued-expression) {
  <!-- loop contents here -->
}

...or...

@for (integer-valued-expression) {
  <!-- loop contents here -->
}

Alternatives considered

Just the clunky alternatives currently available.

Metadata

Metadata

Assignees

No one assigned

    Labels

    area: coreIssues related to the framework runtimecore: control flowIssues related to the built-in control flow (@if, @for, @switch)featureIssue that requests a new feature

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0