Support disabling options in select with ng:options
Need a way to construct
<select>
<option disabled>A</option>
<option>B</option>
<optionC</option>
</select>
There's no way to express the disabled state of a specific option with ng:options
+1
I'd rather get this working with ngRepeat and then you could use ngDisabled to disable the field as need
+1
+1
+1
@IgorMinar I've tried this aproaching, but it added some levels of complexity to the management of ng-model (list of ids) since I had to work with Strings istead of Integer to keep the Select element selecting the right options.
And besides, its much more verbose with ng-repeat.
+1
Edit: select & option with ng-repeat gave me some issues (I guess that's why ng-options exists in the first place), I went for having multiple select with ng-options and hide/show them depending on the context
Instead of using a new directive (the jsfiddles from above) you can simply use ng-repeat:
<select ng-model="item.status">
<option ng-repeat="status in statusList"
ng-selected="status.value === item.status"
value="{{status.value}}"
ng-disabled="status.value === '42'">
{{status.text}}
</option>
</select>
As for the first value (as a placeholder) I use.
<select ng-model"..." ng-options="...">
<option value="" disabled selected>[Make your choise]</option>
</select>
+1
+1
+1
+1 (@tkrotoff Thanks for the workaround :)
+1
@hakanostrom
<select ng-model"..." ng-options="...">
<option value="" disabled selected>[Make your choice]</option>
</select>
does that actually work for you? when i do this it always selects the first (selectable) option, not the default disabled option :(
@connorbode @hakanostrom I have the same issue with
<select ng-model"..." ng-options="...">
<option value="" disabled selected>[Make your choice]</option>
</select>
and Firefox. Chrome and IE11 works fine.
+1
ng-repeat cannot achieve group by easily.
Hope for syntax like
select as label disable if cond group by group for value in array
+1
+1
+1
+1