2016-04-29 127 views
0

角UI路由器UI視圖問題內部UI視圖

的index.html

<div ui-view></div> 

的test.html被裝載的index.html的UI視圖

和測試的內部。 HTML

<div ui-view="content"></div> 

,並試圖加載另一個HTML文件,但它不工作

這裏是我的UI路由器

.state("index", { 
     url: "", 
     templateUrl: "views/index.html", 
     controller : 'MainCtrl', 
     controllerAs : 'main' 
     }) 
     .state("test", { 
     url: "/test", 
     templateUrl: "views/test.html", 
     controller : 'testCtrl', 
     controllerAs : 'test' 
     }) 
     .state("test.another", { 
     url : "another/", 
     views:{ 
      'content':{ 
      templateUrl :'views/another.html' 
      } 
     } 
     }) 

所以基本上是我想到的是

<div ui-view> 
    <!-- test.html --> 
    <div ui-view="test"> 
    <!-- another.html --> 
    </div> 
</div> 
+0

從'test.another'中刪除'views/test.html'。它應該只是爲了意見。所以第一個不是必需的。另外,「另一個@ post」是什麼? AFAIK在你的任何'ui-view'上都沒有這個標籤。 – cst1992

+0

請勿更改所有代碼並刪除您的所有評論。否則沒有人會知道我在說什麼。 – cst1992

回答

0

我看到兩個問題:

.state("test.another", { 
    templateUrl: "views/test.html", 
    views:{ 
     '[email protected]':{ 
     templateUrl :'views/another.html' 
     } 
    } 
    }) 

是不需要先templateUrl;它只是爲了觀點,而不是狀態。

另外:

'[email protected]':{ 

這意味着你的目標視圖 '另一個' 在 'post.html'。您既沒有名爲'another'的視圖,也沒有名爲'post.html'的模板。

+0

URL是單獨的。對於root用戶,你將使用'/',對''test'進行測試,對於另一個你將使用'/ another'。 Angular使用URL來內部映射這些狀態。所以最後你會得到'/ test/another /#/'。 – cst1992