Answer the question
In order to leave comments, you need to log in
AngularJS select "nothing was selected, we have to insert the undefined item"?
The problem is this:
jsfiddle.net/agH3b/ is an empty item in the select.
How to get rid of it?
Fellow developers decided that github.com/angular/angular.js/blob/master/src/ng/d...
using css, an attempt to hide such an option in chrome did not result in anything, but in firefox, an interesting behavior
jsfiddle.net/6kZUB/ 1/ - just empty select
jsfiddle.net/6kZUB/2/ - select with empty option (height changed)
jsfiddle.net/6kZUB/3/ - select with empty option (in css display: none) (select with zero height)
jsfiddle .net/6kZUB/4/ - the same, but you can remove the option (even if removeChild is an empty option - the height is still 0, although it should be the same as in the first case)
jsfiddle.net/6kZUB/5/ - here option without css, you can also remove it (the 2nd case is replaced by the 1st)
jsfiddle.net/6kZUB/6/ final result of the 4th (should have been)
-
# lsb_release -a
No LSB modules are available.
Distributor ID: Debian
Description: Debian GNU/Linux 6.0.7 (squeeze)
Release: 6.0.7
Codename: squeeze
$ google-chrome --version && firefox --version
Google Chrome 26.0.1410.63
Mozilla Firefox 20.0
Answer the question
In order to leave comments, you need to log in
Made a pull-request - github.com/angular/angular.js/pull/2590 . They said that people sometimes want an empty option with size>1 and did not accept, but they suggested a way (although it is not entirely logical).
plnkr.co/edit/FkTJ1ECmtbBcNWKBqBib?p=preview
i.e. use attributes
select-maximum="1"
multiple
size
- for now this works for me as a solution
In general, this is a cant of the 'select' directive, they need to check for the presence of the 'size' attribute, so if I were you, I would write them an issue, or make a pull-request, if they have not already done so.
So that it would be easier for other developers to live later.
PS
The spec doesn't say anything about choosing a default element, but an empty element definitely shouldn't be there :)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question