I'm trying to filter a on a nested array inside an array of objects in an Vue.js. Here's a snippet of the component code:
computed: {
filteredProducts: function () { // https://codepen.io/arhey/pen/QrbxdX
return this.products.map(product => {
return product.filter(p => {
return this.powers.includes(p.total_power_lamps);
});
});
}
},
As a result, the data is filtered but not updated on the page.
filteredProducts: Array[6]
0: Array[2] <- Filtered!
1: Array[2] <- Filtered!
2: Array[0] <- Remove?
3: Array[0] <- Remove?
4: Array[0] <- Remove?
5: Array[0] <- Remove?
Can't update data on the page due to empty arrays.
How do I delete empty arrays ?
v-if="product!=null"?