来自主要组件的角延迟加载模块

时间:2020-04-12 11:25:52

标签: javascript angular typescript ecmascript-6 single-page-application

我的app.routing.module.ts中具有以下设置。 enter image description here

app.component.html

<router-outlet></router-outlet>

modules / core / components / home / home.component.html

<mat-sidenav-container autosize>
<mat-sidenav #sidenav role="navigation">
    <!--this is a place for us to add side-nav code-->
    <wn-sidenav-list (sidenavClose)="sidenav.close()"></wn-sidenav-list>
</mat-sidenav>
<mat-sidenav-content>
    <!--in here all the content must reside. We will add a navigation header as well-->
    <wn-header (sidenavToggle)="sidenav.toggle()"></wn-header>
    <main>
        <!-- I want the components child components of the home components to be loaded here -->
        <router-outlet></router-outlet>
    </main>
    <wn-footer></wn-footer>
</mat-sidenav-content>

问题

当我访问localhost:4200 / campaigns或localhost:4200 / dashboard时,会显示它们各自的组件,但它们没有使用其父视图(home.component.html)

我的目标

我希望home组件的所有子组件都显示在home.component.html 的路由器出口中,而其他组件将显示在home的 router-outlet中。 app.component.html

我以前有这样的设置,但是当时我没有使用模块,它运行良好。关于延迟加载,我不了解吗?

1 个答案:

答案 0 :(得分:0)

当我访问localhost:4200 / campaigns或localhost:4200 / dashboard时, 显示了广告系列模块的组件,但未使用 他们父母的(home.component.html)视图

在路线配置中,您使用的是redirectTo:'/dashboard',因此,您将看到广告系列的视图