angular 2 路由配置区分大小写

angular 2 routeconfig case sensitivity

假设我的路由配置如下:

@RouteConfig([
    { path: '/login', name: 'Login', component: LoginPageContainer }
])

可以在 angular2 中订阅路由器,如下所示:

   this.router.subscribe((nextValue) => {
       this.router.navigate(['nextValue']);
    });

在给定的场景中,下一个值将全部为小写,如 "login" 而不是 "Login"。由于 routeconfig 以大写开头定义名称,因此路径将无法解析。

是否可以使 routeconfig 名称不区分大小写,或者有没有办法获得正确大小写的名称?我一直在搜索,但找不到任何关于此的内容。

The name field is the route name which must be spelled in PascalCase to avoid potential confusion with the route path.

如果您想寻求变通办法,您可以使用 navigateByUrl 来让它工作。该方法将基于 URL 采用 Instruction,然后加载与该路由关联的组件。

this.router.subscribe((nextValue) => {
    this.router.navigateByUrl('/'+'nextValue');
});