I am getting values as input and pushing them as an Array to the back end. There are 6 predefined items in the Array in the front end. If I send 6 values there won't be any empty elements inside the array. If I send less than 6 it's creating an empty element. That's a known fact. Now I want to filter out the empty elements before pushing the array.
Actual output
[
{
"ABC_Info": {
"_id": "5c404e2d16e42513905189a1",
"ABC": [
{
"_id": "5c404e2d16e42513905189a7",
"a": "Dosa",
"b": 15,
"c": 30
},
{
"_id": "5c404e2d16e42513905189a6",
"a": "Idly",
"b": 25,
"b": 25
},
{
"_id": "5c404e2d16e42513905189a5",
"a": "Vada",
"b": 25,
"c": 35
},
{
"_id": "5c404e2d16e42513905189a4"
},
{
"_id": "5c404e2d16e42513905189a3"
},
{
"_id": "5c404e2d16e42513905189a2"
}
]
}
}
]
TS
this.abcService.addabc(ABC).subscribe(
res => {
this.abcArray.push(res); //abcArray is a array. Before Pushing I want to check for empty element and remove before pushing
},
error => console.log(error)
);
}
resobject and validate and push only if it is valid. Or you want to filterthis.abcArrayand push in filtered array?