How to list parents and city in angularJS?

1

I want to do the following:

Brazil Rio Grande do Sul South Africa ... and so on.

Can you do this in a table?

<table width="500" border="1">
    <tr>
        <td width="200" align="center">País</td>
        <td width="300" align="center">Estado</td>
    </tr>
    <tr>
        <td>{{pais}}</td>
        <td>{{estado}}</td>
    </tr>
</table>

Country and state are each in a table.

    
asked by anonymous 12.01.2016 / 23:17

2 answers

1

Complete example using your expected return.

You can run the code to test.

angular.module('myApp', [])
  .controller('EstadosController', function() {
    var estados = this;
    estados.lista = [{
      pais: 'Brasil',
      estado: 'Rio Grande do Sul'
    }, {
      pais: 'Brasil',
      estado: 'Santa Catarina'
    }];
  });
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js"></script><divng-app="myApp">
  <div ng-controller="EstadosController as estados">
    <ul class="unstyled">
      <table width="500" border="1">
        <tr>
          <td width="200" align="center">País</td>
          <td width="300" align="center">Estado</td>
        </tr>
        <tr ng-repeat="estado in estados.lista">
          <td>{{estado.pais}}</td>
          <td>{{estado.estado}}</td>
        </tr>
      </table>
    </ul>
  </div>
</div>

If you resolve your issue, please accept the response and vote for it.

    
13.01.2016 / 00:09
0

It does, and it's very simple. Just do this:

<tr ng-repeat="dados in meuScope">
    <td>{{dados.pais}}</td>
    <td>{{dados.estado}}</td>
</tr>

Where meuScope is the value of $scope defined in controller .

Example:

$scope.meuScope = [
    {pais: 'Brasil', estado: 'Rio de Janeiro'},
    {pais: 'Brasil', estado: 'São Paulo'},
    //etc...
];
    
12.01.2016 / 23:46