简体   繁体   中英

ng-change not firing when empty select option is removed

I have a select list in angluarJs, which I have removed the default empty value from (using the answer from this question Why does AngularJS include an empty option in select? ).

Now, when I try and select the first option, the ng-change method doesn't fire. I understand why, the value hasn't changed. However, the ng-change method is calling a function which hides the select element, so I can't click on the 2nd element and then the 1st element again.

I've tried adding an ng-click event, but this responds to any click in the select, even if its not on an option.

is there any way to get around this?

cheers

So i figured this out, its not perfect, but it does what I need.

just add

<option hidden value=""></option>

inside the select tags.

We have had the same issue. To solve this problem we used angularjs ui-select .

This will allow the user to type in the postal code then you can query for a list of possible addresses and the user can pick from there. I hope this helps as it has worked great for us.

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