刷新页面后重定向状态

时间:2018-01-13 10:19:05

标签: angularjs angular-ui-router oclazyload

我使用oclazyload在我的应用中注入模块,ui-router创建状态,一切正常,我可以在州homeusers 之间移动但是当我们将状态更改为users.list并按F5(刷新)状态返回otherwise state (/ application / partials / index.html)刷新页面后我应该怎样做才能保持users.list状态?

的index.html

<div ng-app="app">
    <a ui-sref="/">home</a>
    <a ui-sref="users.list">users</a>

    <div ui-view></div>
    <script src="Scripts/angular.js"></script>
    <script src="Scripts/angular-ui-router.min.js"></script>
    <script src="Scripts/ocLazyLoad.js"></script>

    <script src="app.js"></script>
</div>

主要应用

var app = angular.module("app", ["ui.router", "oc.lazyLoad"]);

app.config(function ($ocLazyLoadProvider, $stateProvider) {
    $ocLazyLoadProvider.config({
      modules: [{
        name: 'users',
        files: ['/application/modules/users/app.js']
      }]
    }); 

    $stateProvider.state('/', {
        url: '/',
        templateUrl: '/application/partials/index.html'
    });

    $urlRouterProvider.otherwise('/');
})

app.run(function ($ocLazyLoad) {
    $ocLazyLoad.load("users");
});

应用/模块/用户/ app.js

var app = angular.module("users", []);

app.config(['$stateProvider', function ($stateProvider) {
    $stateProvider.state('users', {
        abstract: true,
        url: '/users',
        template: '<div ui-view="users"></div>'
    });

    $stateProvider.state('users.list', {
        url: '/list',
        module: "users",
        views: {
            "users": {
                parent: "users",
                templateUrl: '/application/modules/users/partials/index.html'
            }
        }
    });
}]);

0 个答案:

没有答案