AngularJS UI-路由器“否则”状态不加载
问题描述:
我的index.html页面有3次:AngularJS UI-路由器“否则”状态不加载
<header ui-view="header"></header>
<main ui-view="content"></main>
<footer ui-view="footer"></footer>
我只是改变使用的,而不是最初的单一视图,这些3次现场。
所有在我的应用程序做工精细的路线,例如“家”的看法:
$stateProvider.state('home', {
url: '/home',
data: {
pageTitle: 'Home',
access: 'private',
bodyClass: 'home'
},
views: {
'header': {
templateUrl: 'modules/header/header.html'
},
'content': {
controller: 'HomeController as home',
templateUrl: 'modules/home/templates/home.html'
},
'footer': {
templateUrl: 'modules/footer/footer.html'
}
}
});
我的问题是“否则”状态的应用程序无法正确加载了“家”的状态,因为它应该。该页面是空白的,没有控制台错误。这里是我的app.module中的状态:
angular.module('app').config(function ($stateProvider) {
$stateProvider.state('otherwise', {
url: '*path',
template: '',
data: {
pageTitle: '',
access: 'public',
bodyClass: ''
},
controller: function ($state) {
$state.go('home');
}
});
});
我在这里错过了什么?
答
我不确定你的野生字符是否有效。
理想我使用默认路由如下:
$urlRouterProvider.otherwise('/app/home');
你可能只需要设置'$ urlRouterProvider.otherwise( '/ defaultPath'); '在国家定义 –
之后我还没有在''* path''之前看到过这样的事情,那你是什么意思? – Rachmaninoff
别人创造它,我不知道。 – Steve