IE 8 choosing index n + 1

In IE 8, if I have a select list, for example ...

<select required ng-options="n for n in monthNumbers" ng-model="month"> </select> 

... then Angular adds an empty first parameter. Then when I select any option, IE 8 will select the option that appears after it. Therefore, if I select month 1, he will select month 2.

If I add a starting element like this ...

  <select required ng-options="n for n in monthNumbers" ng-model="month"> <option></option> </select> 

... then the problem is fixed. However, then Angular will not remove the empty first element if any other element is selected, which is the behavior I want.

Is there any decent way around this?

+6
source share
3 answers

I added ng-disabled = "true" to the manually added initial parameters and does not allow users to select them in IE 8.

fooobar.com/questions/63092 / ...

+3
source

Use ng-options as follows:

 <select required ng-options="month.value as month.label for month in months" ng-model="month"></select> 
+1
source


set the value of your ng model in ng-init, if you do not assign a value to the model when loading your controller, it detects that the model is empty

0
source

Source: https://habr.com/ru/post/949653/


All Articles