Show values with angle

0

I have the following code:

$http.get('/estados').success(function(retorno) {
    $scope.ufs = retorno.ufs;
    console.log(retorno);
});

and the result of console.log(retorno) is:

NowI'mtryingtoshowthevaluesofthisreturnina<select>ofHTML:

<sectionclass="input-field col l1 s12">
    <i class="material-icons prefix">public</i>
    <select name="uf" required="true">
        <option ng-repeat="(key, value) in ufs">[{value.sigla}]</option>
    </select>
</section>

But it is not showing any value, but when inspecting the element I see the code below:

It is assigning the values to <option> of <select> but on the page for the client select nothing appears.

Has anyone ever gone through this?

NOTE: I am using {[ because I changed the settings.

app.config(function($interpolateProvider) {
    $interpolateProvider.startSymbol('[{').endSymbol('}]'); 
});
    
asked by anonymous 02.04.2016 / 21:50

3 answers

1

ufs is an array , not an object with keys and values.

Instead of using

<option ng-repeat="(key, value) in ufs">[{value.sigla}]</option>

Try

<option ng-repeat="value in ufs">{{value.sigla}}</option>
    
02.04.2016 / 22:43
0

The problem is that you are using [] in the value binding. You're doing it this way:

[{value.sigla}]

The correct would be to use {{value.sigla}}

Example: link

    
02.04.2016 / 22:23
0

Dude, I tried to use it there

$http.get('/estados').success(function(retorno) {
    $scope.ufs = retorno.ufs;
    console.log(retorno);
});

Take a look at ngResource, an example I made in my service.

 var services = angular.module('ProcessoService', ['ngResource']);

    services.factory('ProcessosFactory', function($resource,apiUrl){
      var resource = $resource('http://restTest/retornos');

      var factory = {
          listar: function () {        
              var lista = resource.query({}, function(data){
                 lista = data;
              });
              return lista;
          }


      }


  return factory;

In the controller it only calls:

$scope.lista = ProcessosFactory.listar();

no html:

<tr ng-repeat="processo in processos">
            <td>{{ processo.id }}</td>
<tr>

See if it helps in your case.

    
08.04.2016 / 20:02