我有一个选择下拉列表,如下所示:
<select ng-model="expressionClause.field" ng-options="o.fullPropertyName as o.displayName for o in model.discountExpressionProperties" ng-change="expressionClause.value = ''" required></select>
是否可以在不修改控制器的情况下在其中两个渲染选项中添加“禁用”属性?并且不使用ngRepeat而不是ngOptions?
我试过这个:
<select ng-model="expressionClause.field" ng-options="o.fullPropertyName as o.displayName disable when o.displayName == 'Product ID' for o in model.discountExpressionProperties" ng-change="expressionClause.value = ''" required></select>
但我认为我没有正确使用它,因为我收到语法错误:
Error: [$parse:syntax] Syntax Error: Token 'disable' is an unexpected token at column 15 of the expression [o.displayName disable when o.displayName == 'Product ID'] starting at [disable when o.displayName == 'Product ID'].
LE:AngularJS v1.3.20
答案 0 :(得分:1)
Angular 1.4.0-beta.5的发行说明:
"ngOptions: add support for disabling an option (da9eac86, #638, #11017)"
尝试更新Angular版本。