2015-11-17 139 views
0

我試過在其他線程尋求這方面的幫助,但無濟於事。我知道我正在使用嵌套狀態,並嘗試絕對/相對路線,但它不會從searchResults轉換到attributeDefinition狀態。我使用的UI路由器與下列文件狀態轉變......從父狀態轉換到UI路由器子狀態的問題

<!-- index.html page --> 
<div ai-body> 
    <!-- AngularUI View Pane --> 
    <div class="ai-content content" id="ai-content" ui-view></div> 
</div> 

//index.router.js: Routes 
.state('searchResults', {   //Parent state 
     url: "/searchResults/{app}?keyword", 
     templateUrl: "app/searchResults/searchResults.html", 
     ncyBreadcrumb: { label: 'Search Results' } 
     }) 
     //Attribute Definition 
     .state('searchResults.attributeDefinition', { //child state 
      url: "/attributeDefinition/{action}", 
      templateUrl: "app/attributeDefinition/attributeDefinition.html", 
      ncyBreadcrumb: { label: 'Create Attribute Definition' } 
      }) 

<!-- searchResults state --> 
<a type="button" class="btn btn-primary" ui-sref=".attributeDefinition({action: 'create'})"> 
        Create new definition 
       </a> 

回答

0

我能解決父狀態的有$ stateProvider以下配置未命名的UI視圖加載嵌套的狀態。它使用'views'屬性使用定位未命名視圖(而不是相對)。可能看起來很簡單,但我沒有找到容易解釋的在線文檔,也沒有提供此解決方案的在線示例。請參閱文檔獲取更多信息,這裏[http://bit.ly/VLKhGg] -

$stateProvider //Parent state .state('searchResults', { url: "searchResults/{app}?keyword", views: {"@" : { url: "/searchResults/{app}?keyword", templateUrl: "app/searchResults/searchResults.html" } } }) //Child state .state('searchResults.attributeDefinition', { url: "/attributeDefinition/{action}", parent: 'searchResults', views: {"@" : { url: '/attributeDefinition/{action}', templateUrl: "app/attributeDefinition/attributeDefinition.html" } } })