简体   繁体   中英

ie10+ Angular select issue

I have a fairly simple required which doesn't include ng-option and ng-repeat.So i create select box with two option for all browser evrything works fine but not on ie10+. Any idea what is the root cause?

<select data-ng-model="ctrl.sort" data-ng-change="ctrl.matchSort(ctrl.sort)">
                               <option data-ng-value="p" data-ng-bind="sort.asc"></option>
                               <option data-ng-value="m" data-ng-bind="sort.desc"></option>
                             </select>

Select Drop down is getting created with empty option value string

<option value="?String:p"></option>


By Default : " ctrl.sort = 'p'; "

It appears that your Angular model does not have a default value selected. Hence, Angular may be inserting a default option. In your model, you can use the following code:

$scope.ctrl.sort = 'default'

But here is a better way to do this:

$scope.ctrl = [{value: "default", name: "p"},
               {value: "p",       name: "p"},
               {value: "m",       name: "m"}];

$scope.ctrl.sort = "p";

<select name="ctrlselect"
        id="ctrlselect"
        data-ng-model="ctrl.sort"
        data-ng-change="ctrl.matchSort(ctrl.sort)"
        data-ng-options="option.value as option.name for option in ctrl">
</select>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM