I found a problem that I do not know how to solve.
If you use this template, so there is no problem:
<li *ngFor="#supplier of supplierList | async">
<a (click)="changeSupplier($event)">
<span>{{supplier.id}}: {{supplier.name}}</span>
</a>
</li>
Output is e.g.:
<li>
<a>
<span>1: Sony</span>
</a>
</li>
<li>
<a>
<span>2: Samsung</span>
</a>
</li>
If I edit a template and try to set the "supplier.id" into html attribute "data-supplierid":
<li *ngFor="#supplier of supplierList | async">
<a (click)="changeSupplier($event)" data-supplierid="{{supplier.id}}">
<span>{{supplier.name}}</span>
</a>
</li>
An error appears:
Can't bind to 'supplierid' since it isn't a known native property ("i>
<li *ngFor="#supplier of supplierList | async">
<a (click)="changeSupplier($event)" [ERROR ->]data-supplierid="{{supplier.id}}">
<span>{{supplier.name}}</span>
</a>
Default is property binding. For attribute binding use either
attr.data-supplierid="{{supplier.id}}"
or
[attr.data-supplierid]="supplier.id"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With