Angular 2 ngfor first, last, index loop

Check out this plunkr.

When you’re binding to variables, you need to use the brackets. Also, you use the hashtag when you want to get references to elements in your html, not for declaring variables inside of templates like that.

<md-button-toggle *ngFor="let indicador of indicadores; let first = first;" [value]="indicador.id" [checked]="first"> 

Edit:
Thanks to Christopher Moore:
Angular exposes the following local variables:

  • index
  • first
  • last
  • even
  • odd

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)