Angular - 将边栏添加到仪表板父模块

问题描述 投票:-1回答:1

我构建了一个仪表板父模块,它包含2个子模块:usersModule和statsModule

我想在父模块中显示一个侧边栏来浏览子模块,但我想避免在每个模块中调用侧边栏。最好的方法是什么?

structure

这是我到目前为止所得到的

# dashboardModule
    statsModule
        containers
        components
    usersModule
        containers
        components
    sharedModule
        services
        guards
        pipes
// other stuff
# homeModule
# eventsModule

谢谢

angular architecture structure nav dashboard
1个回答
0
投票

我亲自在我的Angular2项目中使用了Material2 sidenav用于此目的,效果很好。

https://material.angular.io/components/sidenav/overview

**我猜我应该扩展**我在父组件中使用它作为“包装器”div,从该包装器中调用所有我的子组件。

所以在我的情况下,我有一个“sidenav”组件是我的父组件,所有其他子组件在该视图中被调用/呈现。

代码示例

<mat-sidenav-container>
  <mat-sidenav>
  </mat-sidenav>
  <Component-selector></Component-selector>
  //or you can place your router outlet here if your using a router
  <router-outlet></router-outlet>
</mat-sidenav-container>

这是我如何构建我的项目的图像。 enter image description here

© www.soinside.com 2019 - 2024. All rights reserved.