1

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

Community
  • 1
  • 1
Jay
  • 2,077
  • 5
  • 24
  • 39
  • why you want to select the first option again if it is already selecetd – Chakravarthy S M Sep 19 '14 at 11:37
  • some context, this is a post code lookup, so use enters a post code, and I display a list of possible addresses. I don't want the blank line to appear in the select list, but can't actually select the first element, as this may not be the correct address. – Jay Sep 19 '14 at 11:41

2 Answers2

1

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

just add

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

inside the select tags.

Jay
  • 2,077
  • 5
  • 24
  • 39
0

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.

nweg
  • 2,825
  • 3
  • 22
  • 30
  • thanks for the reply, unfortunately I don't think that's going to do what I need. The spec for this is pretty rigid. – Jay Sep 22 '14 at 07:51