Ionic <select> default selected value?

Hello, i’m using Ionic to show a list of options (a select tag), but when the WebView loads, it always show the default value selected as none. My code is as follows:

  <label class="item item-input item-select">
  	<div class="input-label">
	    <i class="icon ion-search placeholder-icon"></i>
    	Filtrar por status
    </div>
    <select ng-model="filtro.attributes.status">
    	<option selected>Todos</option>
        <option value="aberto" selected>Abertos</option>
        <option value="concluido">Concluídos</option>
        <option value="transporte">Em transporte</option>
    </select>
  </label>

I’m trying to make a angular filter based on a select, but i want it to show that ‘Todos’ option when i open the view.

PS, As im Brazilian, all the values are in portuguese :stuck_out_tongue:

Thanks in advance,

Bruno

see this post… http://codepen.io/aaronksaunders/pen/XJeayJ

3 Likes

Thanks arron, that post didn’t solve my problem, but it guided me to it. Turns out that to show what i wanted, i have to put a ‘value’ attribute on the first option as well, like this:

    <option value="" selected>Todos</option> <!-- EMPTY VALUE ATTRIBUTE HERE -->
    <option value="aberto" selected>Abertos</option>
    <option value="concluido">Concluídos</option>
    <option value="transporte">Em transporte</option>

Thanks for the reply :wink:

2 Likes

Thanks Aaron. This is exactly what I was looking for. Spent many hours trying to figure this out from the docs and searches.