Filter Vue Array of Objects
HTML
<script src="https://cdnjs.cloudflare.com/ajax/libs/vue/1.0.24/vue.min.js"></script>
<div id="test">
<button @click="updateRecord(199199, 1000)">
Update
</button>
<hr/>
<pre>{{ products | json }}</pre>
</div>
JavaScript
new Vue({
el: '#test',
data: {
products: [
{
id: 1,
title: "Product 1",
specifications: {
price: 1.55,
discount: 15,
attributes: [
{
l1: 100,
l2: 80,
height:200,
weight: 15,
parameters: [
{
id: 199199,
size: 185
}
]
},
]
}
}
]
},
methods: {
updateRecord: function(identifier, new_size) {
this.products.map(function(product) {
product.specifications.attributes.map(function(attribute) {
attribute.parameters.map(function(parameter) {
if (parameter.id == identifier) parameter.size = new_size;
})
});
});
}
}
})