0

How to delete per index, i have a parameter and remove button i tried to put my parameter inside my remove button but it wont work how to fix that?

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>

  
2

2 Answers 2

0

There is no removeAt in javascript you can use splice instead

 this.uploadAttachments.splice(rowIndex,1);
Sign up to request clarification or add additional context in comments.

Comments

0

I always replace the array reference with a new array where the item to be removed has been filtered out

this.uploadAttachments = this.uploadAttachments.filter((_, i) => i !== rowIndex);

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.