angularjs - build a form using multiple ng repeats how to proccess the data? angular js -


im building cart. each product has "addons" these example

  • size:big
  • dressing: no salad dressing
  • drink: cola

these "addons" database. , returned api objects.

object looks this: object cat_addons (addon_group) -object (addon) -object - etc object item addons (addon_group) -object (addon) -object - etc

now im making "form" wich shows select boxes , stuff , "add" button. when user clicks ok/add want selected values can further process it... have no clue anymore to this, because ng-model has variable because created in repeat.

so im searching option selected values form (multi) ng-repeat populated form how can that?

view:

<form ng-submit="additemtocart()">     <!-- addons -->     <!-- cat addons -->     <div ng-if="cat_addons">         <div ng-repeat="(k, addon_group) in cat_addons">             {{addon_group.addon_group_name}}             <!-- single option-->             <div ng-if="addon_group.addon_option_type == 'single'">             <span>                 <select ng-options="addon.addon_name addon.addon_id addon in addon_group.items">                     <!-- shows nothing? -->                 </select>             </span>             </div>             <!-- single option -->              <!-- multi option-->             <div ng-if="addon_group.addon_option_type == 'multi'">             <span ng-repeat="(k, addons) in addon_group.items">                 <input type="checkbox" name="{{addons.addon_id}}">{{addons.addon_name}}             </span>             </div>             <!-- multi option -->         </div>     </div>     <!-- cat addons -->     <!-- addons -->     <button type="submit">ok</button> </form> 

controller:

        $scope.additemtocart = function() {             //i have no clue...         } 

i understand urge use ng-repeat once discover it's capable of. there lot more angular makes things such issue simpler. might want explore ngoptions directive (https://docs.angularjs.org/api/ng/directive/ngoptions) or select tag (https://docs.angularjs.org/api/ng/directive/select).

if these not you're looking for, try , go through documentation explore angular. i'm sure enjoy it. if still stuck, comment on answer , i'll out. know how implement want using ng-repeat not close best way want to.


Comments

Popular posts from this blog

node.js - Using Node without global install -

How to access a php class file from PHPFox framework into javascript code written in simple HTML file? -

java - Null response to php query in android, even though php works properly -