ReferenceError: Data is not defined

1

I'm doing an application with angularjs 1.6 , it consists in asking a query to a REST service that returns an array of clients, this data I want to place in an array of Objects , however, when creating the new client, the error that is not defined is presented.

this is my object

function Cliente(datos){
this.idCliente = datos.idCliente;
this.idCiudad = datos.idCiudad;
this.nombreCliente = datos.nombreCliente;
this.nit =  datos.nit;
this.direccion = datos.direccion;
this.telefono = datos.telefono;
this.email = datos.email;
this.nombreCompletoContacto = datos.nombreCompletoContacto;
this.telefonoContacto = datos.telefonoContacto;
this.fechaCreacion = datos.fechaCreacion;
this.estado = datos.estado;
this.muestraMandatorio = datos.muestraMandatorio;
this.mostrarLogoCliente = datos.mostrarLogoCliente;
this.fechaIngreso = datos.fechaIngreso;}

the following is the service

app.service("servicioClientes", function($http, $location){
this.listaClientes = function(){
    var url = $location.protocol() + "://"+$location.host() + ":" + $location.port() + "/url/servicio/REST";
    var config = {headers : {'Content-Type': 'application/json;charset=utf-8;'}}
    console.log("Realizando request a " + url);
    return $http.get(url, config);
}}).service("conversorObjetos", function(){
this.convertirClientes = function(listJsonClientes){
    var listaObjetosClientes = [];
    for(var i=0; i<listJsonClientes.length;i++){
        listaObjetosClientes.push(new Cliente(listJsonClientes[i]));
    }
    return listaObjetosClientes;
}});

The following is the driver

app.controller("controladorClientes", 
function($scope, $http, $window, servicioClientes, conversorObjetos, $location){

    $scope.nuevoCliente = {};

    var peticion = servicioClientes.listaClientes();

    peticion.then(function(response){
        if(response.data){

            $scope.listaClientes = conversorObjetos.convertirClientes(response.data);

        }else{
            console.log("response data empty");
        }
    });
});

This is the order of loading the objects

<script type="text/javascript" src="js/controladores/clienteController.js"</script>
<script type="text/javascript" src="js/objetos/cliente.js"></script>
<script type="text/javascript" src="js/servicios/clienteServices.js"</script>

When I am on the page that presents the error, and validate the loaded objects I find the controller and the service, but not the client.js object.

this is the error presented

  

ReferenceError: Client is not defined at Object.convertClients

I appreciate your collaboration, I am new to this and if there are additional suggestions are appreciated.

    
asked by isaac 04.08.2017 в 03:38
source

0 answers