I am creating a new directive for the select element. As a best practice, I would like to receive some of the options from the server and one option I want to create in the client code e.g. "Search all cars".
This is an example of how I want it to look:
<select>
<option value="">Search all cars</option>
<option value="aud">Audi</option>
<option value="bmw">BMW</option>
<option value="maz">Mazda</option>
</select>
It is important that the value of "Search all cars" is empty.
But even though I have added an empty element in the select (ref other SO posts) it still gives me an unwanted option:
<option value="?" selected="selected"></option>
Here is an plunker example of the issue/bug using an Angular directive with transclude and replace.
Anyone got a suggestion of how to solve this?
I have also added an issue to the angular team here.
EDIT:
The reason why I would like to have this as an directive is that I want to decide if I should have the "Search all cars" option or not depending on where it is implemented in my application.
EDIT2: Angular team confirms that this is a bug. "It looks like the root reason is that if an unknown option is added after the initial setup, then it will not replace the generated unknown option" - lgalfaso.