because my angular code does not bring me the content of my database?

0

What happens is that I'm new to this angle and this code I found in a tutorial and try to dock and apparently if you bring the data from the database and confirm it with the php but I can not make it to me those in the list.

conexion.php

<?php
function conexion()
{
    global $DB_HOST;
    global $DB_USER;
    global $DB_PASSWORD;
    global $DB_NAME;

    $DB_HOST= 'localhost';
    $DB_USER= 'root';
    $DB_PASSWORD= '';
    $DB_NAME= 'bdg';

    $mysqli=@new mysqli($DB_HOST,$DB_USER,$DB_PASSWORD,$DB_NAME);
    if (mysqli_connect_errno()){
        printf(error_db_connect());
        exit();
    }
    return $mysqli;
}
?>

list.php

<?php

include ("conexion.php");
$con = conexion();
//$tablas = $_POST['tablas'];
$resultado = $con->query("SELECT * FROM productos ");
$datos = array();
while ($row = $resultado->fetch_assoc()){
    $datos[] = $row;
}

echo json_encode($datos);
?>

product.html

<!doctype html>
<html ng-app = "datosApp">
<head>
<meta charset="utf-8">
<title>Documento sin título</title>

  <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.6/angular.min.js"></script>

</head>
<body>

<div ng-controller = "controladorDatos">
<table>
   <thead>
       <tr>
           <th>idp</th>
           <th>idproducto</th>
           <th>producto</th>
           <th>descripcion</th>
           <th>existencia</th>
           <th>preciocompra</th>
           <th>precioventa</th>
           <th>idproveedor</th>
        </tr>
    </thead>
    <tr ng-repeat="productos in equipo">
        <td>{{productos.idp}}</td>
        <td>{{productos.idproducto}}</td>
        <td>{{productos.producto}}</td>
        <td>{{productos.descripcion}}</td>
        <td>{{productos.existencia}}</td>
        <td>{{productos.preciocompra}}</td>
        <td>{{productos.precioventa}}</td>
        <td>{{productos.idproveedor}}</td> 
     </tr>
</table>
</div>

<script type = "text/javascript">
var misDatos = angular.module('datosApp',[]);
misDatos.controller('controladorDatos',function($scope,$http){      
    $scope.importar = function(){
        $http.get('listar.php').succes(function(datos){
            $scope.equipo = datos;
        });
    }
    $scope.importar();
});
</script>
</body>
</html>
    
asked by Jaime Lopez 30.10.2017 в 04:38
source

1 answer

0

I see you're using angular 1.6

The .success () and. error () method was deprecated in 1.5 and removed in 1.6.

Instead of them, use .then ()

$http.get('listar.php').then(function(response){
        $scope.equipo = response;
});
    
answered by 30.10.2017 в 09:55