Angular2 - 如何为一条路线设置多个路径

时间:2016-09-13 15:42:55

标签: angular dart

我有一个共享多个路线的主要布局的应用。当我在列表路线中时,我想显示一个侧栏。

@Component(
    selector: 'my-app',
    template: '''
<div class="main">
  <router-outlet></router-outlet>
</div>
<div class="sidebar">
  <h3>Sidebar</h3>
  <!-- I want to put a SideBarComponent here when I'm in the Listing route -->
</div>
''',
    directives: const [ROUTER_DIRECTIVES])
@RouteConfig(const [
  const Route(
      path: '/listing',
      name: 'Listing',
      component: ListingComponent, // Add SideBarComponent
      useAsDefault: true),
])
class AppComponent {}

@Component(selector: 'listing', template: '<div>List</div>')
class ListingComponent {}

@Component(selector: 'side-bar', template: '<div>Side bar</div>')
class SideBarComponent {}

如何在RouteConfig中指定多个组件?

0 个答案:

没有答案