I want to merge two lists that are comma separated, CENTURY, BADGER & 65, 85 to form an array like: [{name: 'CENTURY', price: '65'}, {name: 'BADGER', price: 85}], the lists are in an json object:
{
unit: '35 lb',
brands: 'CENTURY, BADGER'
prices: '65, 85'
}
So what I've done is a filter:
angular
.module( 'app.purchases.products' )
.filter( 'mergeDetails', mergeDetails );
function mergeDetails() {
return function ( product ) {
_.merge( product.brands, product.prices );//Using lodash, any suggestion?
console.log('brands ', product.brands);
return product.brands;//`_.merge` will add prices to brands
}
}
I'd like to know how to apply the filter to an interpolation {{ }} so that I could get the array and use it in a ng-repeat, here's where it is used:
<tr ng-repeat="product in products">
<td>{{product.unit}}</td>
<td>
<!-- Here I should filter to ng-repeat the resulting array -->
{{product.brands +' '+ product.prices}}
</td>
</tr>