Obtain multiple values of the option with different ng-model in the same select?

Sorry about my English.
I have a select that is populated by a ng-repeat that fills with available products.
The option to select is precisely the amount that you want to buy. The problem is to associate the number with the product because it is only possible to have a ng-model.
How to proceed?

  <div class="list" ng-repeat="product in products track by product.name">
      <div class="item item-divider">
        <h2>{{product .name}}</h2>
        <p> {{product .value}}</p>
      </div>
      <label class="item item-input item-select">
        <div class="input-label">
        Qtd
        </div>
        <select ng-model="product.qtd">
          <option selected value="">0</option>
          <option value="1">1</option>
          <option value="2">2</option>
          <option value="3">3</option>
          <option value="4">4</option>
          <option value="5">5</option>
        </select>
      </label>
    </div>

<button class="button button-block button-positive" ng-click="send(product)">
  Send
</button>

If I’m understanding you correctly, I’m not entirely sure what the issue is. Since you are using an ng-repeat, the select box’s should be associated to that specific product. I made a plunker and just moved the options into the controller.

See here and let me know if this works:

but you have associated the amount with the product:
ng-model=“product.qtd” --> in this case product is the single product --> so you are storing the value directly on the product.

You repeat loops over all products and the product of the current loop-run is product so everytime you change the quantity you are changing it for the single product. Keep in mind every “product” in the template is only a reference to this “products[$index]”!

So if you are changing the amount of a products the model is in reality this: “products[$index].qtd”

1 Like

Sorry, it works perfectly I really was confusing the functioning of the ng-repeat.
Thanks for the great help!

att