AngularJS - How to generate random value for each ng-repeat iteration

前端 未结 3 1886
挽巷
挽巷 2021-02-14 06:35

I am trying to create random span sized divs(.childBox) of twitter bootstrap using AngularJS.

  
3条回答
  •  心在旅途
    2021-02-14 07:01

    Improvisation of the accepted answer to prevent digest overflow:

    var rand = 1;
    $scope.initRand = function(){
        rand = Math.floor((Math.random()*6)+1)
    }
    
    $scope.getRandomSpan = function(){
      return rand;
    }
    
        
    

提交回复
热议问题