简体   繁体   中英

Disable select option with angular ng-options

following the angular documentation

ng-options guidelines

I write that part of code:

<select ng-model="model" ng-options="item.CODE as item.NAME disable when item.DISABLE for item in list" id="foo" name="foo" ng-change="change()">

but return me back this error:

Syntax Error: Token 'disable' is an unexpected token at column 11 of the expression [{3}] starting at [{4}].

What I'm doing wrong?

You are referring to wrong syntax. For disable with array there is only two syntax available.

  1. label disable when disable for value in array
  2. label disable when disable for value in array track by trackexpr

Try out following:

<select ng-model="model" ng-options="item.CODE disable when item.DISABLE for item in list" id="foo" name="foo" ng-change="change()">

Try updating the angular.js version. This functionality was added in version 1.4.X and above.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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