簡體   English   中英

角度路由 - 路由到惰性模塊子路徑不會啟動組件

[英]Angular routing - routing to a lazy module child path does not initiate the component

在我的app-routing.module中,我有一個懶惰的模塊:

const appRoutes: Routes = [
    { path: 'profile/:id',
        loadChildren: './profile/profile-standalone/profile-standalone.module#ProfileStandaloneModule',
    }
];

這是我的個人資料 - standalone-routing.module-

const routes: Routes = [
    {
        path: '',
        component: ProfileStandaloneComponent,
        children: [
            {
                path: '',
                redirectTo: 'outputa',
                pathMatch: 'full'
            },
            {
                path: 'outputa',
                component: ProfileOutputComponent
            }
        ]
    }
];

@NgModule({
    imports: [RouterModule.forChild(routes)],
    exports: [RouterModule]
})
export class ProfileStandaloneRoutingModule { }

但是當我去url“localhost:4200 / profile / 123 / outputa”時,我的“ProfileOutputComponent”沒有被調用。

知道如何讓它工作嗎?

嘗試這個。

const routes: Routes = [
{
    path: 'outputa',
    component: ProfileOutputComponent
];

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM