Using Angular 4.0.2, I have an *ngFor creating input elements and updating an object array through an add button, but I'm trying to figure out how to update the objects' indeces once an item is removed from that array.
Currently, my ngFor looks like:
*ngFor = let name of names; let i = index
Then, my delete button has a (click) event:
(click)="removeRow(i, names)"
And the method looks like:
removeRow(index:number, names:Names[]){
names.splice(index,1);
index--;
}
But, when I go to update another input element in the array after removing an object, the indeces are incorrect. It appears that "let i = index" in the *ngFor does not decrement, and I apparently cannot just use:
(click)="removeRow(i, names); i--"