1

I have the following function in my controller...

$scope.pagerPages = function (n) {
    var i = Math.ceil(n);
    return new Array(i);
}

the n comes from an expression on the view, and can sometimes be a fraction. Which is why I've done Math.ceil on n.

Anyone know why I would be getting this error?

Invalid array length

EDIT; n is a calculation from the view

<div ng-repeat="i in pagerPages( report.TotalNumRows / report.View.PageSize ) track by $index">
...
</div>

the calculation results in 11.2, which is evidentally working, as on the page i get 12 iterations of the div element, yet it's generating this error?

atmd
  • 7,430
  • 2
  • 33
  • 64
Stuart
  • 1,544
  • 5
  • 29
  • 45

1 Answers1

3

Check the value of i. I suspect it's negative

Even if n was a string or an object it would still work. You'd only get that error is i is a negative number.

i.e. new Array({}) or new Array('ergerg') wont give you an error, but new Array(-2) will give you the error you have

atmd
  • 7,430
  • 2
  • 33
  • 64