Utilize this filter:
Verify your code here: http://jsfiddle.net/qpLuw80j/2/
Defined filter:
var myApp = angular.module('myApp', []);
myApp.filter('range', function() {
return function(input, total) {
total = parseInt(total);
for (var i=1; i<=total; i++) {
input.push(i);
}
return input;
};
});
Using repeat in this manner:
<div ng-repeat="n in [] | range:100">
do something
</div>
Your Code:
HTML:
<div ng-app='app' ng-controller='mainCtrl'>
<div ng-repeat="json in myJson">
<li>{{json.name}}</li>
<select>
<option ng-repeat="n in [] | range:json.qty" ng-bind="n"></option>
</select>
</div>
JS:
var angular = angular.module('app',['QuickList']);
angular.filter('range', function() {
return function(input, total) {
total = parseInt(total);
for (var i=1; i<=total; i++) {
input.push(i);
}
return input;
};
});
angular.controller('mainCtrl', function($scope){
$scope.myJson = [
{
"id": "1",
"name": "banana",
"price": 12,
"qty": 3,
},
{
"id": "2",
"name": "watermelon",
"price": 12.9,
"qty": 4,
}
]
})