2016-04-29 128 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