Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Angular.js ng-option select using keypress

I have a <select> populated via ng-options. In a specific case, when two values are adjacent in the ordered model list and the values have the same first letter, the updating of the model value in angular breaks. This may be a browser event issue but I'm not certain.

This plunker shows the issue and this GIF illustrates it.

I've tried triggering the change event on the field manually without any luck. We would like to keep the list in alphabetical order if possible - changing the order seems to stop the issue.

The issue appears only in Chrome - I'm using Version 43.0.2357.81 (64-bit).

Any ideas would be appreciated. Thanks.

like image 301
phonicx Avatar asked May 27 '15 14:05

phonicx


1 Answers

This is a hack solution and it's ugly but it works.

 <select ng-model="workflowData.section" ng-options="s.name as s.name for s in sections" class="fullwidth" ng-keypress="workflowData.section = s.name">
</select>

I honestly don't know why the original code didn't work.

like image 51
Reasurria Avatar answered Sep 30 '22 00:09

Reasurria