简体   繁体   English

语法错误:令牌“ for”是意外令牌

[英]Syntax Error: Token 'for' is an unexpected token

I'm kinda new to AngularJS, and i'm reading documentations to build a select input using the ng-options directive 我是AngularJS的新手,我正在阅读文档,以使用ng-options指令构建选择输入

https://docs.angularjs.org/api/ng/directive/ngOptions https://docs.angularjs.org/api/ng/directive/ngOptions

my code: 我的代码:

$scope.searchFilterDispatcher.distributionCode = [{
      id: 1,
      label: 'dist1'
    }, {
      id: 2,
      label: 'dist2'
    }];
<select ng-model="searchFilterDispatcher.distributionCode"
    ng-options="item as item.label for item in searchFilterDispatcher.distributionCode| translate | uppercase for item in distributionCode"
    class="form-control" id="distributionCode">
    <option value="">{{'SELECT_A_VALUE' | translate}}</option>
</select>

But when I launch the app the following error rise up: 但是,当我启动该应用程序时,出现以下错误:

"angular.js:12783 Error: [$parse:syntax] Syntax Error: Token 'for' is an unexpected token " “ angular.js:12783错误:[$ parse:语法]语法错误:令牌'for'是意外令牌”

where do I get wrong? 我在哪里弄错了?

Possible Solutions 1. Do not mix translate filter with ng-options. 可能的解决方案1.请勿将翻译过滤器与ng-options混合使用。 try using it seperately 2. uppercase filter should not be on direct ng-option 尝试单独使用2。大写过滤器不应位于直接ng-option上

Try using This 尝试使用此

ng-options="item as (item.label | upper) for item in searchFilterDispatcher.distributionCode"

Thanks 谢谢

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM