我正在尝试在 ang-repeat
中使用字符串连接ui-select2
:
<select ui-select2 ng-model="selected2" style="width:300px;">
<option ng-repeat="item in data[it + 'ems']" selected
value="{{item}}">{{item}}</option>
</select>
(这是一个简单的例子,但字符串连接对于代码重用来说是必要的。)
它在正常情况下工作得很好select
。但是,uiSelect2
会产生错误:
Error: Syntax Error: Token ']' is an unexpected token at column 6 of the expression ['ems']] starting at []].
at Error (<anonymous>)
at throwError (http://code.angularjs.org/angular-1.0.1.js:5830:11)
at parser (http://code.angularjs.org/angular-1.0.1.js:5824:5)
at http://code.angularjs.org/angular-1.0.1.js:6387:29
at compileToFn (http://code.angularjs.org/angular-1.0.1.js:8040:16)
at Object.Scope.$watch (http://code.angularjs.org/angular-1.0.1.js:7547:19)
at http://angular-ui.github.com/angular-ui/build/angular-ui.js:911:19
at nodeLinkFn (http://code.angularjs.org/angular-1.0.1.js:4223:13)
at compositeLinkFn (http://code.angularjs.org/angular-1.0.1.js:3838:14)
at compositeLinkFn (http://code.angularjs.org/angular-1.0.1.js:3841:12) <select ui-select2="" ng-model="selected2" style="width:300px;" class="ng-pristine ng-valid">
转载于此小提琴。
我在这里做错了吗?