angular - Angular2:错误:无法匹配任何路由,当在浏览器地址栏输入 URL 时
我正在尝试在我的 Angular 2 应用程序中实现路由。我的目标是能够使用浏览器地址栏通过 id 显示特定对象。
这是我的路线:
export const appRoutes: Routes = [
{
path: 'intervention/:id',
component: InterventionMainDisplay
},
{
path: 'intervention',
component: InterventionMainDisplay
}
];
我不明白为什么当我在浏览器地址栏输入:http://localhost:3000/intervention 或 http://localhost:3000/intervention/15893 时……没有任何路由被匹配。
在 index.html 中,我有 <head><base href="/" />
我检查了路由器模块配置是否已加载:
@NgModule({
imports: [
RouterModule.forRoot (appRoutes) ], ...
这是完整的错误信息:
Uncaught (in promise): Error: Cannot match any routes. URL Segment: ''
Error: Cannot match any routes. URL Segment: ''
at new Error (native)
at ApplyRedirects.noMatchError