0
This is my Angular Code:
<script>
angular.module("fluxo", ["ngRoute"]);
angular.module("fluxo").config(function ($routeProvider) {
$routeProvider.when("/entradas", {
templateUrl: "views/entradas.html",
controller: "fluxoCtrl"
})
.when("/saidas", {
templateUrl: "views/saidas.html",
controller: "fluxoCtrl"
})
.otherwise({redirectTo: "/index"});
})
.factory('pegaContas', ['$http', function($http) {
var _getContas = function(id_empresa) {
return $http.post("php/index.php", id_empresa);
};
return {
getContas: _getContas
}
}])
.controller("fluxoCtrl", function ($scope, $http, pegaContas) {
//var id_empresa = {id_empresa: id_empresa};
var id_empresa = {id_empresa: 1};
pegaContas.getContas(id_empresa).then(function(data) {
$scope.mostraTodasContasEntradas = data;
console.log(data);
}, function(error) {
console.log("Ocorreu um erro: " + error);
});
});
</script>
And this is my HTML page, where the data should appear:
<div class="container">
<div class="col-md-3">
<table class="table table-striped">
<tr>
<th>Data</th>
<th>Categoria</th>
<th>Subcategoria</th>
<th>Valor</th>
<th>Forma pgto.</th>
<th>Editar</th>
<th>Excluir</th>
</tr>
<tr ng-repeat="conta in contas">
<td>{{conta.data}}</td>
<td>{{conta.categoria}}</td>
<td>{{conta.subcategoria}}</td>
<td>{{conta.valor}}</td>
<td>{{conta.forma_pagamento}}</td>
<td></td>
<td></td>
</tr>
</table>
</div>
</div>
And yes, I’ve done tests and the data is coming from the bank.
I get it, I’m gonna try
– GustavoSevero
Only this appeared on the screen "{"id_empresa":1}" heheheh
– GustavoSevero
Can show your array?
– celsomtrindade
I edited the post, it’s like you suggested.
– GustavoSevero
Array where does data come from? php?
– GustavoSevero
In this case, the array that is being assigned to the "show"
– celsomtrindade
Ta in the code I posted above.
– GustavoSevero
In this case, this
console.log(data);
what it shows on the console?– celsomtrindade
The data coming from the bank.
– GustavoSevero
You want me to put it here, how they’re coming?
– GustavoSevero
This, to know if the array is "readable" for the way you are inserting into html
– celsomtrindade
0: Object Category: "Occasional Rentals/Sale Imob." Date: "04/11/2015" forma_payment: "Blabla" subcategory: "Occasional Rentals/Sale Imob." Value: "100,00"
– GustavoSevero
I put a print here in the post for you to see the array.
– GustavoSevero
I edited the answer, change the value of $Scope to
$scope.mostraTodasContasEntradas = data.data;
– celsomtrindade
Perfect! Closed, are appearing... But pq put date.date?
– GustavoSevero
By the way PHP returns. It returns in this logic data = array -> objects. Then just reference the name of the array and then access it. = D
– celsomtrindade