Saved from https://stackoverflow.com/questions/35405618/ngfor-with-index-as-value-in-attribute
<ul> <li *ngFor="let item of items; let i = index" [attr.data-index]="i"> {{item}} </li> </ul>