Angular: ng-repeat scope - value 14410993
http://angularjs.org/
by manoj
HTML
<div ng-controller="MyCtrl">
<input type="text" ng-model="cntInputs" placeholder="#Inputs"><br/>
<input ng-repeat="i in getTimes()" type="text" ng-model="inputs[i-1]">
<ul>
<li ng-repeat="j in getTimes()">
Inputed value is: {{getValue(j)}}
</li>
</ul>
{{inputs}}
</div>
CSS
input{
width: 20px;
}
JavaScript
var myApp = angular.module('myApp', []);
function MyCtrl($scope) {
$scope.cntInputs = 3;
$scope.inputs = []
$scope.getTimes=function(){
var a = new Array();
for(var i=1; i <= $scope.cntInputs; i++)
a.push(i);
return a;
};
$scope.getValue = function(id){
//here get the value of that inserted in the element with the id of "input_" + id
return $scope.inputs[id-1];
}
}