Skip to content

Instantly share code, notes, and snippets.

@motemen
Last active August 29, 2015 13:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save motemen/8884912 to your computer and use it in GitHub Desktop.
Save motemen/8884912 to your computer and use it in GitHub Desktop.
<!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>
<!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