How to get in angular 2 the index but increased by 1:
<li *ngFor="let mPrepTasks of project.upcomingMeetingsPrepTask; let i= index; let count = i+ 1;">
<p>Index {{count}}</p>
</li>
How to get in angular 2 the index but increased by 1:
<li *ngFor="let mPrepTasks of project.upcomingMeetingsPrepTask; let i= index; let count = i+ 1;">
<p>Index {{count}}</p>
</li>
Why not just do this:
<li *ngFor="let mPrepTasks of project.upcomingMeetingsPrepTask; let i= index;">
<p>Index {{i + 1}}</p>
</li>
You can't create arbitrary template variables. Inside *ngFor
you can only declare variables that are provided by the *ngFor
directive.
Either do what @FilipLauc said or do the calculation in the component class instead.
Use single quote. It doesn't remove any data from the array items and at the same time the index starts from 1 and it ends to items.length.
*ngFor="let item of items; let i = 'index+1'";
© 2022 - 2024 — McMap. All rights reserved.