Can’t bind to ‘for’ since it isn’t a known native property angular2

update

In Angular2 final [for]="xxx" should work fine. They added an alias from for to htmlFor.

original

Angular by default uses property binding but label doesn’t have a property for. To tell Angular explicitly to use attribute binding, use instead:

[attr.for]="someField"

or

attr.for="{{someField}}"

instead.

These also work because htmlFor is the property for is reflected to.

[htmlFor]="someField"
htmlFor="{{someField}}"

In Angular2 RC.6 an alias was added so these should now work as well:

[for]="someField" 

or

for="{{someField}}" 

Leave a Comment