ng-repeat angular

1

I'm developing an application with a GRID and I needed to format the dates coming to this GRID using data filter of Angular.

But I'm not able to print the date array inside the <div> tag, if I put it to start with a <tr> or <td> it works fine, but I'm already using a ng-repeat in <tr> , you would need another ng-repeat only for a given column.

My html:

<table>
<tr>
    <th>Nome</th>
    <th>C.P.F</th>
    <th>CNH</th>
    <th>Categoria</th>
    <th>Vencimento</th>
</tr>
<tr ng-repeat="x in registros | filter : filtro">
    <td><a ng-click = "enviarDadosDetalhe(x)">{{x.nome}}</a></td>
    <td><a ng-click = "enviarDadosDetalhe(x)">{{x.cpf}}</a></td>
    <td><a ng-click = "enviarDadosDetalhe(x)">{{x.rg}}</a></td>
    <td><a ng-click = "enviarDadosDetalhe(x)">{{x.texto_cnh}}</a></td>
    <td><a ng-click = "enviarDadosDetalhe(x)">{{x.datas[$index]}}</a></td>

    <tr ng-repeat = "y in data track by $index">
        <td>{{y | date : "dd/MM/yyyy"}}</td>
    </tr>
</tr>

My function that returns the records in the controller:

$http.get(linkservice + "select").then(function (response) {    
    $scope.registros = response.data;
    $scope.data = [];

    for(var i = 0; i < $scope.registros.length; i++){
        var data = new Date($scope.registros[i].data_nascimento);
        $scope.data.push(data);
    }
    $scope.registros.datas = $scope.data;
    console.log($scope.registros);
});
    
asked by anonymous 01.03.2017 / 00:09

1 answer

1

Your question is not very clear, and it would be much better if you could show an example of the contents of $scope.registros and $scope.data . Still, here's a simplified example of visualization:

<table>
<tr>
    <th>Nome</th>
    <th>C.P.F</th>
    <th>CNH</th>
    <th>Categoria</th>
    <th>Vencimento</th>
</tr>
<tr ng-repeat="x in registros | filter : filtro" ng-click="enviarDadosDetalhe(x)">
    <td>{{x.nome}}</td>
    <td>{{x.cpf}}</td>
    <td>{{x.rg}}</td>
    <td>{{x.texto_cnh}}</td>
    <td>
        <table>
            <tr ng-repeat='y in x.datas'>
                <td>{{y}}</td>
            </tr>
        </table>
    </td>
</tr>
    
01.03.2017 / 15:36