angular.js icon indicating copy to clipboard operation
angular.js copied to clipboard

Support disabling options in select with ng:options

Open esprehn opened this issue 15 years ago • 96 comments

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

esprehn avatar Nov 05 '11 22:11 esprehn

+1

bvaughn avatar Jul 14 '14 16:07 bvaughn

+1

antonchaika avatar Jul 14 '14 16:07 antonchaika

+1

hereswhatidid avatar Jul 17 '14 21:07 hereswhatidid

+1 This is extremely difficult to work out, alalonde's solution is nice but incompatible with 'group by'. At the same time though, it should be a rather simple feature to add to the existing ngOptions directive.

Lennholm avatar Jul 21 '14 17:07 Lennholm

+1

martinsznapka avatar Jul 22 '14 14:07 martinsznapka

+1 and also for @cades' syntax suggestion:

select as label disable if cond group by group for value in array

q00p avatar Jul 22 '14 22:07 q00p

+1

jonathanablanida avatar Jul 25 '14 22:07 jonathanablanida

+1

bmasetto avatar Jul 31 '14 13:07 bmasetto

+1

murillogoncalves avatar Jul 31 '14 14:07 murillogoncalves

+1

zdychacek avatar Aug 01 '14 10:08 zdychacek

+1

FYI, This seems to work decently well:

HTML

<select ng-model="L.selectVal" class="form-control" required="required">
  <option value="" disabled="disabled" selected="selected">-- Select Thingy --</option>
  <option ng-repeat="thingy in L.things" value="{{thingy.id}}">{{ thingy.label }}</option>
</select>

Jade

select.form-control(ng-model="L.selectVal" required="required")
  option(value="" disabled="disabled" selected="selected") -- Select Thingy --
  option(ng-repeat="thingy in L.things" value="{{thingy.id}}") {{ thingy.label }}

coolaj86 avatar Aug 03 '14 04:08 coolaj86

@coolaj86 Not recommend because ng-repeat inside a select will not render correctly on IE. There is an open issue for it : https://github.com/angular/angular.js/issues/2809

exocom avatar Aug 03 '14 20:08 exocom

+1

AndreasHeintze avatar Aug 21 '14 10:08 AndreasHeintze

+1

ojacquemart avatar Aug 29 '14 11:08 ojacquemart

another +1 for @cades recommendation, it's exactly what I was hoping for

select as label disable if cond group by group for value in array

aronduby avatar Sep 03 '14 04:09 aronduby

+1

vasanthps avatar Sep 04 '14 12:09 vasanthps

+1

bertrandg avatar Sep 10 '14 15:09 bertrandg

+1 @alalonde and @vikasgulati - Thank you both for a great fix for this issue. Has anyone updated this directive to be compatible with Group By?

JohnPennington avatar Sep 11 '14 16:09 JohnPennington

+1

Xartok avatar Sep 15 '14 09:09 Xartok

+1

Londeren avatar Sep 19 '14 11:09 Londeren