Inside my formarray i have input fields , i am trying to create a button to swap those field inside the formarray. I want to know how would i find the index of that particular input field
Below is my code
<form [formGroup] ="categoryForm">
<div formArrayName="categories"
*ngFor="let category of categories.controls; let i=index">
<div [formGroupName]="i">
<div class="form-group row mb-2">
<div class="col-md-4">
<input class="form-control"
id ="{{'categoryName' + i}}"
type="text"
placeholder="Category Name (required)"
formControlName="categoryName"
>
</div>
<div class="col-md-1">
<button
(click)="removeCategory(i)"
class="btn btn-danger"
style="padding: 5px"
>
</div>
<div class="col-md-1">
<button
(click)="onSwap(i)"
class="btn btn-danger"
style="padding: 5px"
>
SWAP BUTTON
</button>
</div>
</div>
</div>
</div>
</form>