0

I am trying to use ng-repeat on an integer value which is shared in $scope. My code is-

Html-

<div ng-repeat="t in getTimes({{selected.head.numberOfHead}}) track by 
     $index">{{$index}
</div>

js-

  $scope.getTimes=function(n){
            return new Array(n);
  }

Here, {{selected.head.numberOfHead}} argument in getTimes() is not working. How can I do that???

If I use getTimes({{selected.head.numberOfHead}})

Error: `

[$parse:syntax] Syntax Error: Token '{' invalid key at column 11 of the expression [getTimes({{selected.head.numberOfHead}})]` starting at [{selected.head.numberOfHead}})].

If I use getTimes('{{selected.head.numberOfHead}}')- Its not looping

If I use getTimes({{'selected.head.numberOfHead'}})

Error:

[$parse:syntax] Syntax Error: Token '{' invalid key at column 11 of the expression [getTimes({{'selected.head.numberOfHead'}})] starting at [{'selected.head.numberOfHead'}})].
Paulo Galdo Sandoval
  • 2,173
  • 6
  • 27
  • 44

0 Answers0