In my angular
application, I have two arrays - products
and productsGreen
. The products
array contains all products, while the productsGreen
array only has successful products.
When the user deselects the green checkbox
, I want to remove productsGreen
from products
. Most solutions involve using loops and multiple lines of code.
Is there a way to achieve this in just one line of code, like products.remove(productsGreen)
?
Here is the products
array:
{
"color": "green",
"loc": "L1"
},
{
"color": "green",
"loc": "L2"
},
{
"color": "red",
"loc": "L5"
},
{
"color": "red",
"loc": "L6"
},
And here is the productsGreen
array:
{
"color": "green",
"loc": "L1"
},
{
"color": "green",
"loc": "L2"
},
The desired output should be:
{
"color": "red",
"loc": "L5"
},
{
"color": "red",
"loc": "L6"
},
Edit 1:
Below is the code snippet:
OnChangeGreen($event)
{
if(this.CheckboxGreen==true)
{
this.CheckboxGreen=false;
this.chartData.pop(this.mapDatagreen)
this.mapImageSeries.data=this.chartData;
this.chartData.validateData();
}
}