所以我正在学习角度7中的通配符路由,当我创建错误页面时,该错误页面的内容也会显示在首页中。作为参考,我将组件导出到名为routingComponents
的数组中。考虑到我甚至还保留了错误页面的路径,所以我不知道为什么会发生这种情况,是否应该对HTML文件进行更改?这是我的app-routing.module.ts
代码
const routes: Routes = [
{path:'departments',component: DepartmentListComponent},
{path: 'employees', component: EmployeeListComponent},
{path: "**", component:PageNotFoundComponent}
];
@NgModule({
imports: [RouterModule.forRoot(routes)],
exports: [RouterModule]
})
export class AppRoutingModule { }
export const routingComponenets = [DepartmentListComponent,
EmployeeListComponent,
PageNotFoundComponent]