Good evening!
I have the following:
var carregarUsuario = function () {
$http.get("buscar.php").then(function (retorno){
console.log(retorno.data);
$scope.usuarios = retorno.data;
});
};
carregarUsuario();
And PHP
error_reporting(0);
$user = "root";
$password = "";
$db = "angulardb";
$host = "localhost";
$con = mysqli_connect("localhost", $user, $password, $db);
if (mysqli_connect_errno()){
echo "Erro: " . mysqli_connect_error();
}
$usuario = mysqli_query($con, "SELECT * FROM users");
header('Content-Type: application/json');
$return = array();
while ($dados = mysqli_fetch_assoc($usuario)) {
array_push($return, $dados);
}
echo json_encode($return);
No data is being displayed on the page, or on the console. What can it be?
EDIT
When I put a print_r
in my PHP code, right after while
I have:
Array
(
[0] => Array
(
[0] => 2
[id] => 2
[1] => João Silva
[nome] => João Silva
[2] => [email protected]
[email] => [email protected]
[3] => 123456
[pass] => 123456
)
[1] => Array
(
[0] => 3
[id] => 3
[1] => Mario de Almeida
[nome] => Mario de Almeida
[2] => [email protected]
[email] => [email protected]
[3] => 123456
[pass] => 123456
)
)