[英]angular-ui-router state not loaded on page load
我創建了一個網站,該網站使用angular-ui-router映射到多個視圖。 除以下兩點外,其他一切正常:
$urlRouterProvider.otherwise()
值。 該視圖雖然沒有改變。 我的主模塊如下所示:
angular.module('package.name', [
'ui.router',
'ui.bootstrap',
'package.nameControllers'
]).
config(function($stateProvider, $urlRouterProvider) {
$stateProvider.
state('home', {
url: 'home',
templateUrl: 'templates/home.html',
controller: 'homeCtrl'
}).
state('other', {
url: 'other',
template: 'Another page'
});
$urlRouterProvider.otherwise('/home');
});
我究竟做錯了什么?
我在這個笨拙的人身上也遇到了同樣的情況。 網址不變的示例可以在這里看到。
對頂級狀態的提示應以斜杠開頭。 嘗試添加斜杠:
state('home', {
url: '/home',
templateUrl: 'templates/home.html',
controller: 'homeCtrl'
}).
state('other', {
url: '/other',
template: 'Another page'
});
看這里 。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.