当前位置: 代码迷 >> JavaScript >> 如何在ng-view中使用ng-view?
  详细解决方案

如何在ng-view中使用ng-view?

热度:26   发布时间:2023-06-13 12:10:05.0

我有主要的ng视图,并具有左侧\\右侧的控制器。 右边是固定的,但是我想通过其他模板和控制器来更改左边。

 <div ng-controller="MainCtrl as main">
  Choose:
  <a href="Book/Moby">Moby</a> |
  <a href="Book/Moby/ch/1">Moby: Ch1</a> |
  <a href="Book/Gatsby">Gatsby</a> |
  <a href="Book/Gatsby/ch/4?key=value">Gatsby: Ch4</a> |
  <a href="Book/Scarlet">Scarlet Letter</a><br/>

  <div class="left-side view-animate-container">
    <div ng-view class="view-animate"></div>
  </div>
 <div class="some-fixed-right-side">

  <pre>$location.path() = {{main.$location.path()}}</pre>
  <pre>$route.current.templateUrl = {{main.$route.current.templateUrl}}</pre>
  <pre>$route.current.params = {{main.$route.current.params}}</pre>
  <pre>$routeParams = {{main.$routeParams}}</pre>
  </div>
</div>

我使用了从此处派生的解决方案: :

让我有效地嵌套视图(并完全跳过有限的ng-view)

这样做之后,出现了另一个(更简单,更好,我相信)解决方案:

(向下滚动到“路由检查”)

你不能。 只需使用 。 它允许使用嵌套视图。

  相关解决方案