repeat
Import
Section titled “Import”import { Repeat } from 'ngxtension/repeat';Use the Repeat directive as an extension of Angular’s NgFor to iterate over a fixed number of iterations. The TrackByFunction is automatically set to efficiently iterate.
import { Component } from '@angular/core';import { Repeat } from 'ngxtension/repeat';
@Component({ imports: [Repeat], template: ` <ul> <li *ngFor="let i; repeat: 3">{{ i }}</li> </ul> `,})export class App {}This will produce the following output:
<!-- Output --><!-- <li>0</li> --><!-- <li>1</li> --><!-- <li>2</li> -->Inputs
Section titled “Inputs”n: number- A non-negative integer, specifying the number of iterations.
Validation
Section titled “Validation”- An error is thrown if the input is either negative or not an integer.