Reputation: 45911
I've just started to learn Angular 4 and I have trying to use this array:
public productsByLaw: IHash;
interface IHash {
[row: number]: IProduct[];
}
The productsByLaw
will store an IProduct
array for each row I will display in a <table>
.
In a ngFor
(in the second one of this example):
<tr *ngFor="let productionorder of productionorders; let rowIndex = index">
<td>
<select id="ProductId-{{rowIndex}}" name="ProductId-{{rowIndex}}" #productId="ngModel" [(ngModel)]="productionorders[rowIndex].productid" required>
<option></option>
<option *ngFor="let product of productsByLaw[{{rowIbdex}}]" [value]="product.productId">{{product.name}}</option>
</select>
</td>
But I get a syntax error here: productsByLaw[{{rowIndex}}]
with the {{rowIndex}}
.
I want to use the IProduct[]
array depending on the row where I am.
How can I do what I what to do?
Upvotes: 0
Views: 109
Reputation: 657078
It should be
productsByLaw[rowIndex]
{{}}
is only for string interpolation
Bindings with *
(like in *ngFor="..."
or [foo]="..."
are evaluated as expressions and not strings.
Upvotes: 3