I have a dynamics ng-select and input through an arrayForm.
HTML:
<ng-container formArrayName="bottles">
<div class="col">
<div class="productContainer">
<ng-container *ngFor="let bottle of getBottles.controls; let i=index">
<div [formGroup]="bottle" style="display: flex">
<label for="alias-{{ i }}">Produit:</label>
<ng-select id="productInput" (change)='selectTest($event, i)'
[items]="test[0] | keyvalue" bindLabel="value.name" bindValue="value.quantity" formControlName="product"></ng-select>
<label for="bottleQuantity">Bottles needed: </label>
<input *ngFor="let bott of bottles" style="height: 26px" id="bottleQuantity" type="bottleQuantity" formControlName="bottleQuantity"/><div for="alias-{{ i }}" style="color: green" *ngIf="itemSelected">(Qty: {{itemSelected}})</div>
<span class="material-icons" style="cursor:pointer; color: red" *ngIf="getBottles.controls.length > 1" type="button addClass" (click)="removeBottle(i)">delete</span>
</div>
</ng-container>
<span class="material-icons" style="cursor:pointer; color: green" (click)="addBottlesInput()">add_circle</span>
</div>
</div>
</ng-container>
What i'd like is to display the own quantity of bottles for each dynamic field using index. But i don't know how to perform this using index (or an easier way ? )
<div for="alias-{{ i }}" style="color: green" *ngIf="itemSelected">(Qty: {{itemSelected}})</div>
See an example here StackBliz
Thank you for help :)
indexis always 1. Check and correct your structure. Seems like a design problem