0

我根据状态使用 ui-sref 进行路由。目前,我在父级中获取孩子的视图作为层次结构。我想将孩子的视图分配给父视图。当前状态如下plunker

[链接][//plnkr.co/edit/fpsTWglicbcGMotJIlll]

点击点击我后,我想看到欢迎。

4

2 回答 2

0

如果我正确理解了您的问题,那么问题是您将 inner 作为 tab1 的孩子...所以它显示在 tab1 的 ui-view 中。如果你想让它代替tab1,那么你不需要tab1中的ui-view。

这是一个分叉的 plunker 显示我的意思。

http://plnkr.co/edit/t4cxejVLGf4kywKp2bb5?p=preview

我改变的部分:

.state("main", { abtract: true, url:"/main", templateUrl:"main.html" })
.state("main.tab1", { url: "/tab1", templateUrl: "tab1.html" })
.state("main.inner",{
  url:"/inner",
  templateUrl:"inner.html"
})
.state("main.tab2", { url: "/tab2", templateUrl: "tab2.html" })

在 tab1.html

<div>
    This is the view for tab1
    <a ui-sref="main.inner">click me</a>
</div>

这就是你要拍的吗?

于 2015-07-20T18:42:53.993 回答
0

加入$scope.$state = $state;控制器。

然后添加ng-hide="$state.current.name === 'main.tab1.inner'"

 <h2 ng-hide="$state.current.name === 'main.tab1.inner'">View:</h2>

<div ng-hide="$state.current.name === 'main.tab1.inner'">
This is the view for tab1
<a ui-sref="main.tab1.inner">click me</a>
</div>

这是链接 [链接] http://plnkr.co/edit/Yvlp6RNF69yiSq1HfMcf?p=preview

于 2015-07-20T20:15:54.023 回答