Angular 2 - dynamic "for" attribute in ngFor

angular, label, ngfor

Solution

You have to access label's attribute like this: `[attr.for]="'ques-' + i"`

Problem

When i write dynamic "for" attribute in label, i get error. example: ``` <div *ngFor="let question of questions; let i = index;"> <input id="ques-{{i}}" type="radio" name="selected" [value]="question"> <label for="ques-{{i}}">{{question.data}}</label> </div> ``` the error : Unhandled Promise rejection: Template parse errors: Can't bind to 'for' since it isn't a known property of 'label'. the dynamic "id" attribute working fine, please help me to find a solution

Original source

Related problems