I'm trying to make a mini application in angular but I get an error when executing it.
My controller:
var app = angular.module("pacientesApp",[]);
//controller
app.controller("controladorPacientes", function controllerPacientes($scope, $http){
$http.get("../pacientesJSON.php").success(function(r){
$scope.pacientes = r.pacientes;
});
});
This calls a php:
<?php
$usuario ="root";
$pwd = "";
$servidor = "localhost";
$db = "loquesea";
$link = mysql_pconnect($servidor, $usuario, $pwd);
if(!$link){
header("location:error_mysql.html"); exit;
}
if(!mysql_select_db($db)) {
header("location:error_mysql.html"); exit;
}
//buscar todos los registros
$query = "SELECT * FROM paciente ORDER BY ID";
//se guarda el resultado de la query
$resultado = mysql_query($query)
or die ("Error FATAL al buscar datos de $db: " .mysql_error());
$i = 0;
$registros = mysql_num_rows($resultado);
print '{"pacientes": [';
while( $renglon = mysql_fetch_object($resultado)){
print "{";
$nombre = $renglon->nombre;
$apellidos = $renglon->apellidos;
$edad = $renglon->edad;
$domicilio = $renglon->domicilio;
$telefono = $renglon->telefono;
$email = $renglon->email;
$dni = $renglon->dni;
print '"nombre":"'.$nombre.'",';
print '"apellidos":"'.$apellidos.'",';
print '"edad":"'.$edad.'",';
print '"domicilio":"'.$domicilio.'",';
print '"telefono":"'.$telefono.'",';
print '"email":"'.$email.'",';
print '"dni":"'.$dni.'",';
print "}";
$i++;
if($i<$registros){
print ",";
}
}
print "]}";
mysql_close($link);
?>
and inside my html I call my controller:
<body>
<div ng-app="pacientesApp" ng-controller="controladorPacientes">
<ul>
<li ng-repeat="p in pacientes">
{{p.nombre+", "}}
</li>
</ul>
</div>
</body>
The question is that when I open it in localhost it does not show me anything, and if I see it in the console it sends me the following error:
I can not find the fault.