AngularJS For Loop with Numbers & Ranges

后端 未结 24 3453
抹茶落季
抹茶落季 2020-11-22 13:40

Angular does provide some support for a for loop using numbers within its HTML directives:

do something <
24条回答
  •  暗喜
    暗喜 (楼主)
    2020-11-22 14:40

    This is jzm's improved answer (i cannot comment else i would comment her/his answer because s/he included errors). The function has a start/end range value, so it's more flexible, and... it works. This particular case is for day of month:

    $scope.rangeCreator = function (minVal, maxVal) {
        var arr = [];
       for (var i = minVal; i <= maxVal; i++) {
          arr.push(i);
       }
       return arr;
    };
    
    
    

提交回复
热议问题