Deleting for an array (may be a defect)

#1

I am trying to build a functionality to have user get a list with checkbox and number of elements they choose, I need to delete it.

When I select all items to delete, the last item does not get deleted. here is my code

currentProductlinks: Productlink;
deletedLink: Productlink;

deleteFromCart(){
this.deletedLink=this.currentProductlinks
for(let links of this.currentProductlinks){
if(links.selected){
this.deletelinks(links)
}
}
this.storage.set(‘emailLinks’, this.deletedLink)
this.currentProductlinks = this.deletedLink
}

deletelinks(item:any){
for(let links of this.deletedLink){
var index = this.deletedLink.indexOf(links)
this.deletedLink.splice(index,1)
}

I believe array gets resize and the one item gets pushed upwards in an array and skips that one element.

Let me know how to address this issue in IONIC/Angular