angular.js - An issue with loops in angular directives
怪我咯
怪我咯 2017-05-15 17:04:57
0
1
542

There is a variable a=30;
How to loop out the thirty numbers from 1 to 30 in the angular html command? It is not the output of an array, it is a loop of numbers with a step size of 1

怪我咯
怪我咯

走同样的路,发现不同的人生

reply all(1)
漂亮男人

I can’t think of a better way. To operate an array with ng-repeat, you must create an array

html

<p ng-app="app">
  <p ng-controller="MainCtrl">
     <p ng-repeat="item in arr track by $index">
          {{$index+1}}
     </p>
  </p>
</p>

js

angular.module('app', []).controller('MainCtrl', function($scope){
    $scope.a = 30;
    $scope.arr = new Array($scope.a);
});

https://jsfiddle.net/hjzheng/...

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template