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

时间:2018-08-31 13:07:13

标签: angular architecture structure nav dashboard

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

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

structure

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

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

谢谢

1 个答案:

答案 0 :(得分: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

相关问题