2016-03-08 64 views
0

我有一個帶側欄(「菜單」)和主內容div(「main」)的根頁面(index.html),所以兩個ui-view divs - 一個叫做「菜單」和一個叫做「main」的菜單。 enter image description hereAngular UI路由器 - 基於另一個UI視圖更改子菜單的UI視圖

當主要內容區域包含網站列表(/ sites)時,我希望邊欄成爲通用菜單。我已經實現了這個採用了棱角分明的UI的「意見」屬性的特定網址(即https://github.com/angular-ui/ui-router/wiki/Multiple-Named-Views

$stateProvider 
    .state('sites', { 
    views: { 
     'main': { ... list of sites template ... }, 
     'menu': { ... generic menu template ...}, 
    } 
    }) 

當我點擊一個特定的網站(/網站/:網址),我想與填充主要內容區域該網站的頁面,並將菜單更新爲網站選項的特定菜單。

enter image description here

$stateProvider 
    .state('sites.detail', { 
    views: { 
     'main': { ... sites.detail template ...}, 
     'menu': { ... specific site options menu ...}, 
    } 
    }) 

有了這個,看着源時,可以正確生成的鏈接(HREF有/網站/),但點擊一個鏈接時,沒有任何反應 - 沒有視圖更新/改變。有沒有更好的方法來嘗試這個?孩子們的意見是否必須以某種方式相互溝通?

回答

1

您必須正確引用視圖。您可以使用絕對的命名在這種情況下:

$stateProvider 
    .state('sites.detail', { 
    views: { 
     '[email protected]': { ... sites.detail template ...}, 
     '[email protected]': { ... specific site options menu ...}, 
    } 
    }) 

的更多信息: https://github.com/angular-ui/ui-router/wiki/Multiple-Named-Views

+0

謝謝,我最後不得不用主要佈局(@)和其他基本狀態(APP)包含的觀點引用此(即left @ app)。 .state('app',{ views:{ '@':{templateUrl:'views/partials/layout.html',...},'left @ app':{'views/partials/main_menu .html',...}等等。 – Vixxd