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

Popular posts from this blog

java - Oracle EBS .ClassNotFoundException: oracle.apps.fnd.formsClient.FormsLauncher.class ERROR -

c# - how to use buttonedit in devexpress gridcontrol -

nvd3.js - angularjs-nvd3-directives setting color in legend as well as in chart elements -