簡體   English   中英

頁面加載時未加載angular-ui-router狀態

[英]angular-ui-router state not loaded on page load

我創建了一個網站,該網站使用angular-ui-router映射到多個視圖。 除以下兩點外,其他一切正常:

  1. 導航到沒有角度路線的網站時,不會加載任何視圖。
  2. 無論用戶導航到哪個URL,瀏覽器都會將該URL重置為我的$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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM