In my Angular application, I have a Reactive Form with a feature that allows users to add or remove rows. Each row has its own delete button. However, there is an issue where clicking on the delete button for a specific item results in the last row being removed instead. Upon debugging, I noticed that the index returned is -1, indicating that the last item will be deleted.
delete_communityList_row(id) {
const index = this.Form.value.communityList.indexOf(id);
this.Form.value.communityList.splice(index, 1);
}
Despite the delete button correctly returning the "id" of the clicked row, I am unsure why the deletion is not working as expected. The console.log output shows an array of objects.