【发布时间】:2016-09-01 15:39:57
【问题描述】:
如何在角度 2 中获取索引但增加 1:
<li *ngFor="let mPrepTasks of project.upcomingMeetingsPrepTask; let i= index; let count = i+ 1;">
<p>Index {{count}}</p>
</li>
【问题讨论】:
标签: angular angular2-template angular2-directives
如何在角度 2 中获取索引但增加 1:
<li *ngFor="let mPrepTasks of project.upcomingMeetingsPrepTask; let i= index; let count = i+ 1;">
<p>Index {{count}}</p>
</li>
【问题讨论】:
标签: angular angular2-template angular2-directives
为什么不这样做:
<li *ngFor="let mPrepTasks of project.upcomingMeetingsPrepTask; let i= index;">
<p>Index {{i + 1}}</p>
</li>
【讨论】:
您不能创建任意模板变量。在*ngFor 中,您只能声明由*ngFor 指令提供的变量。
要么按照@FilipLauc 所说的去做,要么在组件类中进行计算。
【讨论】: