我正在尝试对$ scope中共享的整数值使用ng-repeat。 我的代码是 -
HTML -
<div ng-repeat="t in getTimes({{selected.head.numberOfHead}}) track by
$index">{{$index}
</div>
JS -
$scope.getTimes=function(n){
return new Array(n);
}
此处{{selected.head.numberOfHead}}
中的getTimes()
参数无效。我怎么能这样做?
如果我使用getTimes ({{selected.head.numberOfHead}})
错误: `
[$parse:syntax] Syntax Error: Token '{' invalid key at column 11 of the expression [getTimes({{selected.head.numberOfHead}})]` starting at [{selected.head.numberOfHead}})].
如果我使用getTimes('{{selected.head.numberOfHead}}')
-
它没有循环
如果我使用getTimes({{'selected.head.numberOfHead'}})
错误:
[$parse:syntax] Syntax Error: Token '{' invalid key at column 11 of the expression [getTimes({{'selected.head.numberOfHead'}})] starting at [{'selected.head.numberOfHead'}})].