Can someone help me figure out how to delete an item by index in Angular? I have a parameter and a remove button, but when I tried putting my parameter inside the remove button it didn't work. How can I fix this?
deleteRowFiles(rowIndex: number){
this.getListFileName();
if(this.uploadAttachments.length > 1){
Swal.fire({
title: 'Are you sure?',
text: 'You will not be able to recover this data!',
icon: 'error',
showCancelButton: true,
confirmButtonText: 'Confirm',
cancelButtonText: 'Cancel'
}).then((result) => {
if(result.value){
this.uploadAttachments.removeAt(rowIndex);
this.microSvc.deleteFile(this.iData.transactionType,this.uploadedFiles).pipe(
return this.refreshPage();
})
}else if (result.dismiss === Swal.DismissReason.cancel){}
})
}
HTML
<td (click)="deleteRowFiles(i)">
<i class="fa fa-trash fa-2x"></i>
</td>