[Angular 2] *ngFor with index

Let's see how to track index when we use 'ngFor:

            <li *ngFor="#hero of heros | async, #i = index">
               <hero-item [hero]="hero" (changed)="thisHero = $event;" [index]="i"></hero-item>
            </li>

#i = index, simple as that :)

原文地址:https://www.cnblogs.com/Answer1215/p/5361916.html