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
+1
Made up a quick directive here - https://github.com/knivets/angular-options-disabled
+1
+1
also It good to have some functionality to skip particular option
For eg.
ng-options="page.id as page.name for page in pages" ng-option-skip="page.id === 100"
the above code should skip rendering an option html when particular psge.id value is 100 in this case.
PS: ng-if can be used here, but it would be better if ng-option itself has some functionality.
@jparmar: Wouldn't you use a filter in that case to modify the collection that ng-options is rendering? This enhancement is needed because you still want to render an item in the collection as an option, but have it be disabled, which a filter won't help you with.
@knivets @chadreed-intl +1 for the dynamic options issue.
@chadreed-intl Did you find a solution to make it work for dynamic options? I'm having a hard time figuring it out!
I think this is applicable while there is no way to do this via ng-options:
<option ng-repeat="option in myOptions" value="{{ option.key }}" ng-disabled="option.disabled">
{{ option.label }}
</option>
$scope.myOptions = [{
key: 'key1',
label: 'Key #1'
}, {
key: 'key2',
label: 'Key #2',
disabled: true
}];
ng-repeat on option doesn't work in IE (at least IE8). It was mentioned here https://github.com/angular/angular.js/issues/638#issuecomment-51002615
@alalonde
In this example: http://jsfiddle.net/alalonde/dZDLg/9/
Set value from test to null for selectedPort variable like this $scope.selectedport = null; The code will break...It does not disable untill we select some option... Could you help me how to fix this issue?
Thanks Prem.
When the this directive http://jsfiddle.net/alalonde/dZDLg/9/
is used inside ag-grid,The disbled property is not applied to he options until we do a selection in the select box.
could you please help on this?
@anilkganhari, since you seem to be using angular-options-disabled, you should probably ask the question in their repo. This is not related to core Angular.
BTW, the ngOptions DSL now supports "disable when" for disabling specific options (see docs).
(Make sure that your Angular version has this feature, before using it.)
Still nothing native to Angular ?
@fredericlam, see https://github.com/angular/angular.js/issues/638#issuecomment-170361383.
@gkalpak Wow, sorry, and thanks
funka capo! bien ahi alto team...estoy sin celular no me funcionan los botones, calculo que el sabado como mucho lo cambio, mientras tanto nos comunicamos por este medio
2015-11-25 13:35 GMT-03:00 Dishant Mehta [email protected]:
you can fix this bug like Test 1 Test 2
— Reply to this email directly or view it on GitHub https://github.com/angular/angular.js/issues/638#issuecomment-159664164.