TypeError: Can not read property 'output' of undefined

0

I see an error, which I interpret happens because the method I try to call or invoke does not exist. The strange or strange of all this, is that I use the same way to inject the service, and this error does not occur, well without further ado, I will place the code and the explanation.

historial.js

angular.module('historialApp', ['ionic', 'ngCordova', 'horarioEstudiante', 'calificacionesEstudiante'])    
       .controller('borrarHistorial', borrarHistorial)
       .factory('salirApp', salirApp);

salirApp.$inject = ['$ionicPlatform', '$ionicHistory', '$timeout', '$cordovaSQLite'];

function salirApp($ionicPlatform, $ionicHistory, $timeout, $cordovaSQLite) {

    function salida() {

        var BackButton = 0;

        $ionicPlatform.registerBackButtonAction(function() {            

            if ($ionicHistory.currentStateName() == 'menuestu' || $ionicHistory.currentStateName() == 'menuprof') {

                if (BackButton === 0) {

                    BackButton++;
                    window.plugins.toast.showLongCenter("Presione nuevamente para salir");

                    $timeout(function() {
                        BackButton = 0;
                    }, 2500);

                } else {
                    navigator.app.exitApp();
                }

            } else {
                if ($ionicHistory.currentStateName() == 'login') {
                    navigator.app.exitApp();
                } else {
                    $ionicHistory.goBack();
                }
            }

        }, 100);

    }

    return {
        salida: salida
    };

}

In this file I have a factory , which, when I inject the module in another, and I call the method, when I need it.

horarioestu.js

angular.module('horarioEstudiante', ['ionic', 'ngCordova', 'btford.socket-io', 'historialApp'])
       .controller('mostrarHorarioEstu', mostrarHorarioEstu);


mostrarHorarioEstu.$inject = ['$scope', 'obtenerHorarioEstu', 'socket', 'salirApp'];

function mostrarHorarioEstu($scope, obtenerHorarioEstu, socket, salirApp) { 

    salirApp.salida();

}  

In the code above, I inject the% historialApp , to call the factory salirApp , and then invoke the salida

method

perfiltu.js

angular.module('perfilEstudiante', ['ionic', 'ngCordova', 'historialApp'])
       .controller('mostrarPerfilEstu', mostrarPerfilEstu);

mostrarPerfilEstu.$inject = ['$scope', 'obtenerPerfilEstu', '$cordovaCamera', '$cordovaFile', 'salirApp'];

function mostrarPerfilEstu($scope, obtenerPerfilEstu, $cordovaCamera, $cordovaFile, salirApp, $element) {   

    salirApp.salida();

}

In the code exposed above in the file perfilestu.js , where I do the same as in the horarioestu.js file, but when I go to this interface it appears the error.

TypeError: Cannot read property 'salida' of undefined at new mostrarPerfilEstu
    
asked by Pedro Miguel Pimienta Morales 05.08.2017 в 20:57
source

0 answers