Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Simple @repeat(n) needed for control flow #61292

Copy link
Copy link
Open
@kshetline

Description

@kshetline
Issue body actions

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 runtimeIssues related to the framework runtimecore: control flowIssues related to the built-in control flow (@if, @for, @switch)Issues related to the built-in control flow (@if, @for, @switch)featureIssue that requests a new featureIssue that requests a new feature

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.