Search code examples
javascriptangularjsangularjs-ng-options

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?


Solution

  • 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()">