基本用法:

    1. export class AppComponent {
    2. heroes = ['Windstorm', 'Bombasto', 'Magneta', 'Tornado'];
    3. }
    4. <p>Heroes:</p>
    5. <ul>
    6. <li [id]="'list-' + hero" *ngFor="let hero of heroes">
    7. {{ hero }}
    8. </li>
    9. </ul>

    也可以获取 index 索引:

    1. <div *ngFor="let hero of heroes; let i=index">{{i + 1}} - {{hero.name}}</div>