Angular2 binding of "name" attribute in <input> elements with *ngFor
final answer
Use ([name]="fruit"
or name="{{fruit}}"
) and ([attr.name]="fruit"
or attr.name="{{fruit}}"
) together will work.
update
If you want to use the string 'fruit'
as value for the name
attribute, use
name="fruit"
or
name="{{'fruit'}}"
or
[name]="'fruit'"
otherwise you bind the value of the components field fruit
(which your component doesn't seem to have)
original
Angular does property binding by default. If you want attribute binding you need to make that explicit
attr.name="{{fruit}}" (for strings only)
or
[name]="fruit"
See also