Loop Iteration Indexes in Angular

When looping through *ngFor and @for, you can get not only the array elements, but also their numbers. Let's see how this is done. Let's say we have an array in the main component:

app/app.component.tsexport class AppComponent {
  public arr: string[] = ['a', 'b', 'c', 'd'];
}

Let's print both its elements and numbers.

For the *ngFor directive, a special trick is used for this:

app/app.component.html<ul>
  <li *ngFor="let el of arr; let i = index">
    {{ i }}
    {{ el }}
  </li>
</ul>

And for the @for construction, you can simply take and use this variable inside the loop:

app/app.component.html<ul>
  @for (el of arr; track $index) {
    <li>
      {{ $index }}
      {{ el }}
    </li>
  }
</ul>
Задание 1

Given an array:

app/app.component.tsexport class AppComponent {
  public arr: string[] = ['a', 'b', 'c', 'd'];
}

Print its numbers, but so that they start with one, not zero.