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

前端 未结 1 1716
离开以前
离开以前 2020-11-29 10:25

I have to Create a list of checkboxes dynamically so i have used *ngFor to iterate the array of objects everything is working fine till iteration. the problem is occured whe

1条回答
  •  情深已故
    2020-11-29 10:39

    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}}" 
    

    0 讨论(0)
提交回复
热议问题