I'm struggling to figure out how to change the value of an attribute in a v-for loop.
For instance, I would like the index to be used as the name of the related product:
HTML
<div v-for="(index, publication) in publications">
{{ index | name publication.productId }}
</div>
JS
filters: {
name: function(val, productId) {
this.$http.get('/api/product/'+productId)
.then(function(rst) {
return rst.data.name;
}).catch(function(err) {
console.error(err);
});
}
},
The request successfully returns the name, but it doesn't seem to appear in the HTML template. I suspect this is because the filter is synchronous.
If anyone has a solution, I'd greatly appreciate hearing about it!