We have several drop-down lists in our application in which we can NOT use ng-options , because we need to set the title attribute to the <options> tag, which is impossible with ng-options .
The reason we need a headline is because IE <9 discards values ββthat are long, and they are visible only with the heading (displayed when you hover over an item)
Now, to see the problem, I am looking at the following JS script.
http://jsfiddle.net/nstuart/nF7eJ/ (HTML bit)
<div ng-app="myApp" ng-controller="MyCtrl"> <select ng-model="params.value"> <option value="">Any</option> <option ng-repeat="v in options" value="{{v.value}}" title="{{v.name}}" ng-selected="{{v.value == params.value}}">{{v.name}}</option> </select> <p>{{params.value}}</p> </div>
Ideally, select will select "test3", but you can see that instead it will be set to an empty parameter. I understand that this is due to the fact that the value of the ng model is missing from ng-options , but this is because I did not define one!
Any ideas on how to make something like this work? Perhaps he can even add a header to the parameters generated by ng-options so that we can use this instead?
EDIT
Updated script: http://jsfiddle.net/nstuart/nBphn/2/ , as described in the answer below.
source share