Let's assume we have a variable called `mylist`
this.mylist.push([{key:{"test1":name,"test":desc,"hi i am a test":other,"none":type,"amount":0} }]);
This data will be added to the `mylist` array. However, under certain conditions, I want to remove the newly created list by deleting it using its unique key.
To achieve this, I need to splice the object array in order to remove the specific value and avoid duplicates.
I attempted to remove the item like this:
this.mylist.splice(this.mylist.indexOf(key), 1);
Unfortunately, this approach didn't work as expected. I aim to eliminate the array based on the unique key that holds these sub values.
I also made an attempt with the following code:
this.mylist.splice(this.mylist.indexOf([{key}]), 1);
If anyone could provide support, I would greatly appreciate it :(
CheckBox(values,values,values) {
this.bool = (this.mylist.indexOf(key) === -1);
if (this.bool) {
this.mylist.push([{key:{"key":key,"naam":naam,"beschrijving":beschrijving,"type":type,"aantal":aantal} }]);
}
else {
this.mylist.splice(this.mylist.indexOf(key), 1);
}
}
The above function is triggered when a user clicks on a checkbox. If the condition is met (`true`), the array should be populated with values. Otherwise, the array containing the unique key should be removed to prevent duplicate entries.