Home How to get selected option in be selected in a dropdown after opening a modal in AngularJS?
Reply: 0

How to get selected option in be selected in a dropdown after opening a modal in AngularJS?

user938
1#
user938 Published in April 21, 2018, 3:24 pm

I have a select tag like this:

<select... ng-model="someProperty" ng-change="openSomeDialog()">
   <option value=""></option>
   <option value="Test1">Test1</option>
   <option value="Test2">Test2</option>
</select>

The openSomeDialog() function opens a ui.bootstrap.modal directive modal. When the user closes the modal, the dropdown reverts to the initial option which is the empty one (first option) instead of what the user has selected. I also tried to use a watch on the select's ngModel and I get the same issue.
If I put some non modal related logic in the function instead of opening a modal, the selection works fine so it seems the process of opening the modal changes the events workflow or something.

How do I get the dropdown to select what the user has selected before the modal opened, after the modal closes?

You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.248249 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO