我使用oclazyload
在我的应用中注入模块,ui-router
创建状态,一切正常,我可以在州home
或users
之间移动但是当我们将状态更改为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'
}
}
});
}]);