use*_*469 0 typescript angular
I am using the traditional ngFor for iterating across an array followed with index, my sample code:
<div *ngFor="let object of Objects; let i = index">
Run Code Online (Sandbox Code Playgroud)
I want to know is it possible to get the last index from the array in i? I know I can find the first or any other by if i === 1, etc, but is there a method to check directly if i is the last one from the array? Thanks.
小智 5
<div *ngFor="let object of Objects; let i = index; first as isFirst; last as isLast">
Run Code Online (Sandbox Code Playgroud)
isFirst and isLast will be booleans.
But then again, the documentation explains it !
| 归档时间: |
|
| 查看次数: |
142 次 |
| 最近记录: |