javascript - Setting a function as a ng-model -
i have complex structure of data (products of shopping cart), this:
items = [ { id_product: 5, combinations: [ { id_product_attribute: 35, quantity: 1, price: 25.60 }, { id_product_attribute: 38, quantity: 4, price: 25.60 } ] }, { id_product: 5, combinations: [ { id_product_attribute: 35, quantity: 1, price: 28.60 } ] } ];
i have ng-repeat
lists, in li
elements, every combination of product retrieved $resource
. each li
element looks this:
<li>combination {{ combination.id }} - price {{ combination.price }} - in shopping cart {{ function_goes_here(product.id, combination.id) }}</li>
i'm wondering if it's possible write kind of function search in shopping cart data structure (by product id , combination id) , return quantity element, in such way update view if combination of same type added shopping cart?
on $scope/scope define function:
$scope.items = [ { id_product: 5, combinations: [ { id_product_attribute: 35, quantity: 1, price: 25.60 }, { id_product_attribute: 38, quantity: 4, price: 25.60 } ] }, { id_product: 5, combinations: [ { id_product_attribute: 35, quantity: 1, price: 28.60 } ] } ]; $scope.function_goes_here = function(productid, combinationid){ //search through $scope.items return "lorem ipsum"; }
Comments
Post a Comment