1
I am developing an application with a GRID and I needed to format the dates coming to this GRID using data filter
angular.
However I am not being able to print the date array inside the tag <div>
, if I put to print in a <tr>
or <td>
works, but I’m already using a ng-repeat in <tr>
, 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 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);
});
The date you want to use in a separate column, it is part of the object
registros
? Or is an array a part, as itscontroller
?– celsomtrindade
@Celsomtrindade So I tried it both ways, actually, at first, it was a separate array, but I thought I’d put cmo object in records, to use a single ng-repeat, but still, the column is empty
– Matheus Minguini