I can not delete my ionic browsing history

2

I inject the modules in the app.js, which is the main one, but when I want to add the HistorialApp driver inside any of the templates in the menus, there is an error , or it does not load the view of the corresponding menu.

Libraries on the 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);
    }
  });        
});

history.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();
    }
}

HTML Menu

<ion-header-bar class="bar-balanced" align-title="center">
    <p class="title">Menu Estudiante</p>
</ion-header-bar>

<ion-view>    
    <ion-content has-header="true"> 
        <div class="container" ng-controller="HistorialApp">
           <!--Contenido-->
        </div>
    </ion-content>
</ion-view>

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

Use the back button on Android to exit the app when you are in the views of one of the two menus

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');
                }
            }
    });
});
    
asked by Pedro Miguel Pimienta Morales 14.03.2016 в 22:01
source

1 answer

1

Pedro, the error is the order in which you are injecting the dependencies of your files js

You say

<script src="js/app.js"></script>
<script src="App/login.js"></script>
<script src="App/historial.js"></script>
<script src="App/ExitApp.js"></script> 

However, app.js has a dependency injection to 'Historia' , which does not yet exist because it is below.

The correct thing would be:

<script src="App/historial.js"></script>
<script src="App/ExitApp.js"></script> 
<script src="js/app.js"></script>
<script src="App/login.js"></script>
    
answered by 27.10.2016 в 21:05