export class AppComponent implements OnInit {
title = 'bucketList';
bucketList: BucketListItem[] = [
new BucketListItem(
"Goa Trip",
"Travel to Goa"
)
];
ngOnInit() {
}
onItemAdded(eventData) {
this.bucketList.push(new BucketListItem(eventData.itemName, eventData.itemDescr));
}
onItemDeleted(delData) { //delData = "Goa Trip"
console.log(this.bucketList); //prints {"itemName":"Goa Trip","itemDescr":"Travel to Goa"
this.bucketList = this.bucketList.filter(function (obj) {
return obj.itemName !== delData;
});
console.log(this.bucketList); //prints {"itemName":"Goa Trip","itemDescr":"Travel to Goa"
}
}
The goal is to eliminate an element from the array by matching its itemName, specifically when itemName equals "Goa Trip". However, the removal process does not succeed.