Select list option selected with AngularJs

4

I'm implementing a select list that has options the Brazilian states.

I would like to return the selected value according to the return of a web service. For example, if the service returns RJ then RJ must be the option selected .

This is very simple to implement with Javascript and Jquery, but I've never done it in Angular. Anyone have a suggestion?

 <select id="txtUf" class="customSel">
    <option value="0" selected="selected">Selecione</option>
    <option value="AC">AC</option>
    <option value="AL">AL</option>
    <option value="AP">AP</option>
    <option value="AM">AM</option> 
    ...
 </select> 
    
asked by anonymous 07.01.2015 / 15:45

1 answer

6
<select id="txtUf" class="customSel" ng-model="Dados.uf">
    <option value="0" selected="selected">Selecione</option>
    <option value="AC">AC</option>
    <option value="AL">AL</option>
    <option value="AP">AP</option>
    <option value="AM">AM</option> ...  
</select> 

The solution would be to include ng-model , "data.uf" is the value of the state acronym, remembering that the value of Data.uf must be equal to the value of the value of the option.     

07.01.2015 / 15:49