I am unable to bind to the list attribute of an input element using [list]="..." syntax. I get the error
Can't bind to 'list' since it isn't a known property of 'input'
Obviously, if I just use list="..." in the template it works. But I need to be able to bind to a component variable.
UPDATE: I'll try to make it clearer why I need to bind like this: [list].
My code looks like this:
component.ts
public arr = [ { name: 'Input1', autocomp: [1, 5, 10, 22], }, { name: 'Input2', autocomp: [0.2, 0.3, 0.4], }, { name: 'Input3', autocomp: [4, 5, 6], }, ]; component.html
<input *ngFor="let item of arr" [id]="item.name" /> <datalist *ngFor="let item of arr" [id]="item.name + '-datalist'"> <option *ngFor="let num of item.autocomp" [value]="num">{{ num }}</option> </datalist> Each input needs to reference the corresponding datalist. Ideally, I would just do:
<input *ngFor="let item of arr" [id]="item.name" [list]="item.name + '-datalist'" /> But this gives me the error.