Last active
August 29, 2015 13:56
-
-
Save motemen/8884912 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html ng-app> | |
<head> | |
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.12/angular.js"></script> | |
<script> | |
// 10 $digest() iterations reached. Aborting! | |
function MainCtrl ($scope) { | |
$scope.numRepeat = 1; | |
$scope.gen = function () { | |
for (var a = [], i = 0; i < $scope.numRepeat; i++) { | |
a.push({ i: i }); | |
} | |
return a; | |
}; | |
} | |
</script> | |
</head> | |
<body ng-controller="MainCtrl"> | |
<input type="number" ng-model="numRepeat"> | |
<p ng-repeat="g in gen()">{{g}}</p> | |
</body> | |
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html ng-app> | |
<head> | |
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.12/angular.js"></script> | |
<script> | |
function MainCtrl ($scope) { | |
$scope.numRepeat = 1; | |
$scope.$watch('numRepeat', function () { | |
for (var a = [], i = 0; i < $scope.numRepeat; i++) { | |
a.push({ i: i }); | |
} | |
$scope.genResult = a; | |
}); | |
} | |
</script> | |
</head> | |
<body ng-controller="MainCtrl"> | |
<input type="number" ng-model="numRepeat"> | |
<p ng-repeat="g in genResult">{{g}}</p> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment