0

I have a problem when i click on backspace it doesn't go to the last page i don't know how to fix it sometime it does go the last page only when i go from app.home page to app.newJob.Step1 and press backspace it goes back to home but not always

here is my router

'use strict';

angular.module('ijob').
config(function ($stateProvider, $urlRouterProvider) {

        $stateProvider
        .state('login', {
            url: '/login',
            templateUrl: 'Views/login.html',
            data: {
                requireLogin: false
            }
        })
        .state('app', {
            abstract: true,
            template: '<ui-view/>',
            data: {
                requireLogin: true
            }
        })
        .state('app.home', {
            url: '/home',
            templateUrl: '/Views/home.html'
        })
        .state('app.editJob', {
            url: '/editJob',
            templateUrl: 'Views/editJob.html'
        })
        .state('app.purchasePackages', {
            url: '/purchasePackages',
            templateUrl: 'Views/purchasePackages.html'
        })
        .state('app.accountDetails', {
            url: '/accountDetails',
            templateUrl: 'Views/accountDetails.html'
        })
        .state('app.jobOrder2', {
            url: '/jobOrder2',
            templateUrl: 'Views/jobOrder2.html'
        })
        .state('app.newJob', {
            abstract: true,
            templateUrl: 'Views/newJob/newJob.html',
            url: '/newJob'
        })
        .state('app.newJob.Step1', {
            url: '/newJob/step1',
            templateUrl: 'Views/newJob/step1.html'
        })
        .state('app.newJob.Step2', {
            url: '/newJob/step2',
            templateUrl: 'Views/newJob/step2.html'
        })
        .state('app.newJob.Step3', {
            url: '/newJob/step3',
            templateUrl: 'Views/newJob/step3.html'
        })
        .state('app.newJob.Step4', {
            url: '/newJob/step4',
            templateUrl: 'Views/newJob/step4.html'
        })
        .state('app.newJob.Step5', {
            url: '/newJob/step5',
            templateUrl: 'Views/newJob/step5.html'
        });

    $urlRouterProvider.otherwise('/home');
    // $locationProvider.html5Mode(true);
})
    .config(function config() {

    });

and my app

'use strict';

// Declare app level module which depends on views, and components
angular.module('ijob', [
    'ui.router', 'ngRoute', 'btorfs.multiselect', 'ngCookies', 'ngResource'
]);

var app = angular.module('ijob');

app.run(['$state', '$cookieStore', '$rootScope', 'Auth', 'UserService',
    function ($state, $cookieStore, $rootScope, auth, userService) {
    $rootScope.$on('$stateChangeStart', function (event, toState, toParams) {
        var requireLogin = toState.data.requireLogin;

        if (requireLogin && !($cookieStore.get('authdata'))) {
            event.preventDefault();
            $state.go('login');
        }
        else if ($cookieStore.get('authdata') && $state.current.name !== toState.name) {
            userService.token = auth.getCredentials($cookieStore.get('authdata'));
            console.log(userService);
            $state.current.name = toState.name;
            $state.go(toState.name);        
        }

    });

}]);

sometimes i get that error

Error: No such state 'app.newJob.Step1'
or
Error: No such state 'login'

and the states do exist.

its something about the ui router?

or there is anyway to override that?

Erez
  • 574
  • 1
  • 6
  • 23
  • need to tell us what current state youre in when this error happens. what states does it actually go back? – atsituab Feb 24 '16 at 14:21
  • its was once but not anymore when i i was on home page and went to app.newjob.step1 -- edit question – Erez Feb 24 '16 at 14:29

0 Answers0