angular - Can't bind to 'for' since it isn't a known native property angular2 -


i have create list of checkboxes dynamically have used *ngfor iterate array of objects working fine till iteration. problem occured when set value of for attribute in label tag. angular has throw error :

can't bind 'for' since isn't known native property angular2

new error message

unhandled promise rejection: template parse errors: can't bind 'for' since isn't known property of 'label'.

<div *ngfor="#batch of batch_array">      <label for="{{batch.id}}"><input type="checkbox" [value]="batch.id" id="{{batch.id}}"            (click)="batchselectedeevent(batch.id)" /> {{batch.batch_name}}       </label> </div> 

here plnkr showing error : http://plnkr.co/edit/aaqfwvhc7h7ibuyzpito?p=preview

whats wrong here in code ?

update

in angular2 final [for]="xxx" should work fine. added alias for htmlfor.

original

angular default uses property binding label doesn't have property for. tell angular explicitly use attribute binding, use instead:

[attr.for]="somefield" 

or

attr.for="{{somefield}}" 

instead.

these work because htmlfor property for reflected to.

[htmlfor]="somefield" htmlfor="{{somefield}}" 

in angular2 rc.6 alias added these should work well:

[for]="somefield"  

or

for="{{somefield}}"  

Comments

Popular posts from this blog

sublimetext3 - what keyboard shortcut is to comment/uncomment for this script tag in sublime -

java - No use of nillable="0" in SOAP Webservice -

ubuntu - Laravel 5.2 quickstart guide gives Not Found Error -