I'm crazy. What is wrong this hi-mundane example? I am trying to just check out some basic things with angularjs 1.5.5.
HTML:
<div ng-app="myApp" ng-controller="Ctrl"> <h3>test 1:</h3> <span ng-repeat="label in test(1)">{{label}}</span> <h3>test 2:</h3> <span ng-repeat="label in test(2)">{{label}}</span> </div>
JS:
angular.module('myApp', []) .controller('Ctrl', ['$scope', function ($scope) { $scope.test = function(amount) { var result = []; result.push("1"); for (var i = 0; i < amount; i++) { result.push("2"); } result.push("3"); return result; } }]);
JsFiddle: http://jsfiddle.net/d3v6vq7w/7/
Nice, the loop works with 1 iteration, but not with Example 2. Nothing is printed. What gives?
source share