angularjs - 退格不起作用

时间:2016-02-24 13:48:01

标签: javascript angularjs backspace

点击退格键时遇到问题 它没有进入最后一页 我不知道如何解决这个问题,只有当我从app.home页面转到app.newJob.Step1并按退格键回到家但不总是

这是我的路由器

'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() {

    });

和我的应用

'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);        
        }

    });

}]);

有时我会收到错误

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

并且各州确实存在。

关于ui路由器的事情?

或者无论如何要覆盖它?

0 个答案:

没有答案