title: Angularjs: Custom array size/array-size as customizable drop-down
body: <p>I am new to angularjs. I am trying to create a shoppinng cart app. So far it's going smooth. However, I need to add 'Quantity' field to 'Add Items to shop' section. This quantity should reflect as drop-down with that many number of units for given item. </p>
  
  <p>The user should be able to select quantity every time and amount should be price of item * qty of items + total items. Can i achieve this?</p>
  
  <pre><code>&lt;!DOCTYPE html&gt;
  &lt;html&gt;
  &lt;head&gt;
      &lt;script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.0.7/angular.min.js"&gt;&lt;/script&gt;
  &lt;/head&gt;
  &lt;body ng-app="myApp" ng-controller="myCtrl"&gt;
      &lt;h1&gt;Select item(s) and add to cart:&lt;/h1&gt;
      &lt;div ng-repeat="item in items"&gt;
          &lt;label&gt;
              &lt;input type="checkbox" ng-model="item.isSelected" /&gt;
              &lt;span&gt;{{item.name}}&lt;/span&gt;
              &lt;span&gt;{{item.price}}&lt;/span&gt;
          &lt;/label&gt;
      &lt;/div&gt;
      &lt;hr&gt;
      &lt;p&gt;Add items to shop&lt;/p&gt;
      Enter name: &lt;input type="text" ng-model="newItemname" /&gt;
      Enter price: &lt;input type="text" ng-model="newItemprice" /&gt;
      &lt;button ng-click="addtoshop()"&gt;Add to shop&lt;/button&gt;
      &lt;hr&gt;
      &lt;h1&gt;Add items to shopping cart&lt;/h1&gt;
      &lt;button ng-click="addtocart((items | filter : { isSelected:true }))"&gt;Shop!&lt;/button&gt;
      &lt;hr&gt;
      &lt;p ng-model="amount"&gt;{{amount}}&lt;/p&gt;
      &lt;script&gt;
          var app = angular.module('myApp', []);
          app.controller('myCtrl', function ($scope) {
              $scope.items = [
              { name: "Bread", price: 20, isSelected: false },
              { name: "Butter", price: 25, isSelected: false },
              { name: "Jam", price: 30, isSelected: false },
              ];
              $scope.addtoshop = function () {
                  var newitem = {};
                  newitem.name = $scope.newItemname;
                  newitem.price = $scope.newItemprice;
                  newitem.qty = $scope.newItemqty;
              }
              $scope.addtocart = function (index) {
                  alert("You chose " + index.length + " items.");
                  var p = 0, i;
                  for (i = 0; i &lt; index.length; i++) {
                      p += parseInt(index[i].price);
                  }
                  alert("Shopping price: " + p);
                  $scope.amount = p;
              };
          });
      &lt;/script&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>