Quantcast
Channel: Ionic Forum - Latest topics
Viewing all articles
Browse latest Browse all 70429

Error using $ionicHistory and onHardwareBackButton

$
0
0

@PterPmnta wrote:

inject the modules in the app.js which is the main , but when I add the driver HistorialApp within any of the menu templates get any errors , or load the appropriate menu view .

HEAD

<script src="lib/ionic/js/ionic.bundle.min.js"></script>
<script src="lib/ngCordova/dist/ng-Cordova.js"></script>
<script src="cordova.js"></script>
<script src="js/app.js"></script>
<script src="App/login.js"></script>
<script src="App/historial.js"></script>
<script src="App/ExitApp.js"></script>

App.js

`angular.module('unicesarApp', ['ionic', 'ngCordova', 'Historial', 'Salida'])

 .run(function($ionicPlatform) {

  $ionicPlatform.ready(function () {

if (window.cordova && window.cordova.plugins.Keyboard) {

   cordova.plugins.Keyboard.hideKeyboardAccessoryBar(true);
   cordova.plugins.Keyboard.disableScroll(true);

}


 });

});`

historial.js

  `        angular.module('Historial', ['ionic'])
          .controller('HistorialApp', HistorialApp);


HistorialApp.$inject = ['$ionicHistory', '$state'];

 function HistorialApp($ionicHistory, $state){

if ($state.is('menuestu') || $state.is('menuprof')) {
    $ionicHistory.clearHistory();
}

}`

login.js

    `angular.module('unicesarApp', ['ionic'])
            .controller('formulario', formulario)
            .service('obtenerDatos', obtenerDatos)
            .config(config);


config.$inject = ['$stateProvider', '$urlRouterProvider'];

function config($stateProvider, $urlRouterProvider) {

    $urlRouterProvider.otherwise("/login");

             $stateProvider

                    //Ingreso

                    .state('login', {
                        url: '/login',
                        templateUrl: "Templates/login.html",
                        controller: "formulario"
                    })
                    .state('Loading',{
                         url: '/loading',
                         templateUrl: "Templates/loading.html"
                    })

                    //Estudiante

                    .state('menuestu',{
                         url: '/menuestu',
                         templateUrl: "Templates/Estudiante/menuestu.html"
                    })
                    .state('perfilestu',{
                         url: '/perfilestu',
                         templateUrl: "Templates/Estudiante/perfilestu.html"
                    })
                    .state('horarioestu',{
                         url: '/horarioestu',
                         templateUrl: "Templates/Estudiante/horarioestu.html"
                    })
                    .state('calificaciones',{
                         url: '/calificaciones',
                         templateUrl: "Templates/Estudiante/calificaciones.html"
                    })
                    .state('calendarioestu',{
                         url: '/calendarioestu',
                         templateUrl: "Templates/Estudiante/calendarioestu.html"
                    })

                    //Profesor

                    .state('menuprof',{
                         url: '/menuprof',
                         templateUrl: "Templates/Docente/menuprof.html"
                    })
                    .state('perfilprof',{
                         url: '/perfilprof',
                         templateUrl: "Templates/Docente/perfilprof.html"
                    })
                    .state('horarioprof',{
                         url: '/horarioprof',
                         templateUrl: "Templates/Docente/horarioprof.html"
                    })
                    .state('grupos',{
                         url: '/grupos',
                         templateUrl: "Templates/Docente/grupos.html"
                    })
                    .state('calendarioprof',{
                         url: '/calendarioprof',
                         templateUrl: "Templates/Docente/calendarioprof.html"
                    });

    };`

ExitApp.js

`angular.module('Salida', ['ionic', 'ngCordova'])

.run(function($ionicPlatform) {

var closeApp = false;

$ionicPlatform.onHardwareBackButton(function ($state, $cordovaToast) {

        if ($state.is('menuestu') || $state.is('menuprof')) {

                if (closeApp === true) {
                    navigator.app.exitApp();
            }

            else {

                    closeApp = true;

                    $timeout(function () {
                        closeApp = false;
                    }, 2000);

                    $cordovaToast.show('Presione nuevamente para salir', 'long', 'bottom');

            }

        }

});

});`

Posts: 1

Participants: 1

Read full topic


Viewing all articles
Browse latest Browse all 70429

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>