Weedoze Weedoze - 5 months ago 9
AngularJS Question

Angularjs input to increase a number of element

I have a simple input to enter a number.

When I enter a number, I want this number of buttons created directly below.

Example : I type in "8" in the input.
8 buttons are created below

<input type="text" placeholder="Number of steps" ng-model="nbrOfSteps">

Answer
<input type="number" ng-model="itemNumber" ng-change="generateButtons()">
<div>
  <button ng-repeat="button in list track by $index">button#{{$index}}</button>
</div>

In Controller

$scope.generateButtons = function(){
   $scope.list = [];
    for(i=0;i<$scope.itemNumber;i++){
        $scope.list.push("");
    }
}

https://jsfiddle.net/ebinmanuval/oqopaw5r/