Quantcast
Channel: Ionic Framework - Ionic Forum
Viewing all articles
Browse latest Browse all 49229

Deleting for an array (may be a defect)

$
0
0

@makarchus wrote:

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

Posts: 1

Participants: 1

Read full topic


Viewing all articles
Browse latest Browse all 49229

Trending Articles