2016-07-05 99 views
1

我得到了一個子狀態,假設將內容加載到ui-view,稱爲ui-solution。它在用戶處於創建稱爲「解決方案」的流程中時這樣做。奇怪的部分是,一旦保存並且用戶重新訪問調用相同子狀態的過程的特定部分,則它不加載內容。任何人都可以發現此代碼可能導致這種不一致行爲的任何錯誤?就這樣我可以排除這一點並開始尋找其他地方。ui路由器,URL更改,沒有命中控制器,內容將不會加載,只有在重新加載

  • 的URL變化
  • 網址具有相同的參數
  • 在頁面重新加載正確的內容在`UI-view``

頁面的加載設置是

ui-view
- 標籤
- ui-view="ui-solution"

$stateProvider.state('analyse', { 
      url: '/analyse/:id', 
      data: { 
       solution: false 
      }, 
      templateUrl: 'app/components/a/a.html', 
      controller: 'Analisys' 
     }); 

     $stateProvider.state('analyse.solution', { 
      url: '/solution', 
      data: { 
       solution: true 
      }, 
      views: { 
       'ui-solution': { 
        templateUrl: 'app/components/a/s/s.html', 
        controller: 'Analisys' 
       } 
      } 
     }); 

ui-view="ui-solution"出現在標籤有

+0

我有同樣的問題,你從分析國家繼承和它首先加載a.html並沒有UI的觀點有 – Erez

+0

我稱之爲特定視圖「用戶界面 - 解決方案「,這樣應該沒關係吧?我也試着添加一個沒有名字的'ui-view'。 @Erez –

+0

我的意思是它首先啓動a.html,並從我理解它加載該視圖,並尋找內部的a.html或第一個ui視圖(空的)內的ui-view解決方案 – Erez

回答

0

嘗試加載嵌套的看法,是不是在你的父視圖,以便它不能加載的a.html一個 - 我有同樣的問題 我建議看看這也是2個鏈接我的評論發送

$stateProvider 
     .state('analyse', { 
      url: '/analyse/:id', 
      data: { 
       solution: false 
      }, 
      templateUrl: 'app/components/a/a.html', 
      //controller: 'Analisys' better using ng-controller in the html instead of here 
     }) 
     .state('analyse.solution', { 
      url: '/solution', 
      data: { 
       solution: true 
      }, 
      views: { 
       'ui-solution': { 
        templateUrl: 'app/components/a/s/s.html' 
       } 
      } 
     }); 

和你a.html應該像

<div ng-controller="Analisys as ctrl"> 
    <h1 ui-serf="analisys.solution">should load the nested view</h1> 
    <div ui-view="ui-solution"></div>//here should see the nested html 
</div> 

和index.html應該有

<div ui-view></div> 

希望它會幫助你

BTW

你不需要的ui-view="solution"導致其自動參考UI的視圖中(除非你有幾個

所以你可以這樣做

$stateProvider 
      .state('analyse', { 
       url: '/analyse/:id', 
       data: { 
        solution: false 
       }, 
       templateUrl: 'app/components/a/a.html' 
       //controller: 'Analisys' better using ng-controller in the html instead of here 
      }) 
      .state('analyse.solution', { 
       url: '/solution', 
       data: { 
        solution: true 
       },      
       templateUrl: 'app/components/a/s/s.html' 
      }); 

和a.html

<div ng-controller="Analisys as ctrl"> 
    <h1 ui-serf="analisys.solution">should load the nested view</h1> 
    <div ui-view></div>//here should see the nested html 
</div> 
相關問題