2016-07-05 101 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> 
相关问题