Skip to content

Instantly share code, notes, and snippets.

@motemen motemen/badangular.html
Last active Aug 29, 2015

Embed
What would you like to do?
<!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
You can’t perform that action at this time.