我正在按照角度路由&导航示例。但我的页面显示为路由时未找到的文件。现在,当我转到profile.component.html的个人资料页面时,我会看到我的列,但我看不到UserComponent
app / profile / profile.component.html
<app-header></app-header>
<div class="some-columns">
hi
</div>
<router-outlet></router-outlet>
目前位于app / profile / profile.module.ts
const profileRoutes: Routes = [
{
path: '',
redirectTo: '/user',
pathMatch: 'full'
},
{
path: 'user',
component: UserComponent,
children:[
{
path:'',
redirectTo: 'album',
pathMatch: 'full'
},
{
path:'album',
component: AlbumComponent
}
]
},
];
@NgModule({
imports: [
CommonModule,
RouterModule.forRoot(
profileRoutes,
{ enableTracing: true }
)
]
})
在我的app.routing.ts中我没有包含子页面,但即使我这样做,它仍然是相同的。
const routes: Routes =[{ path: 'profile', component: ProfileComponent, data: {title: 'Profile'}},]
app.component.ts中的
我导入imports: [ProfileModule]
答案 0 :(得分:0)
根据我的理解,您了解到您在以下路线上有一个配置文件模块:
myapp.com/profile
根据您的路线访问它时,它应该重定向到:
myapp.com/profile/user
您的路由指示的下一件事是用户的第一个子节点是空路径,因此在加载用户时它应默认加载。该路径也是一个重定向,因此最终路径应该像这样结束:
myapp.com/profile/user/album
我建议删除用户组件的子项然后检查。