Angular 区分空路径和无参数

Angular 区分空路径和无参数,angular,angular-router,Angular,Angular Router,我想创建一个有两条路线的角度SPA: http://mydomain/ <- Shows homepage http://mydomain/2017 <- Shows results for 2017 http://mydomain/2018 <- Shows results for 2018 但是,访问http://mydomain将呈现结果组件;路由参数将只是空的 如果参数:resultId存在,我如何通知路由器它应该只与ResultComponent

我想创建一个有两条路线的角度SPA:

http://mydomain/       <- Shows homepage
http://mydomain/2017   <- Shows results for 2017
http://mydomain/2018   <- Shows results for 2018
但是,访问
http://mydomain
将呈现
结果组件
;路由参数将只是空的


如果参数
:resultId
存在,我如何通知路由器它应该只与
ResultComponent
匹配?

使用
pathMatch:full
空路径路由配置,如下所示:

export const MyAppRoutes: Routes = [ 
    { path: "",  component: HomepageComponent, pathMatch: full },
    { path: ":resultId",  component: ResultComponent },
];

pathMatch:full
与空路径路由配置一起使用,如下所示:

export const MyAppRoutes: Routes = [ 
    { path: "",  component: HomepageComponent, pathMatch: full },
    { path: ":resultId",  component: ResultComponent },
];