Angular2版本:rc3
路由器版本:3.0.0-alfa7
boot.ts:
import { provideRouter, RouterConfig } from '@angular/router';
import {AppComponent} from "./main/app.component"
import {UsersComponent, UserListComponent, UserEditComponent} from "./users/index"
export const routes: RouterConfig = [
{ path: "", redirectTo: "users", terminal: true },
{
path: "users",
component: UsersComponent,
children: [
{ path: "create", component: UserEditComponent },
{ path: "edit/:id", component: UserEditComponent },
{ path: "", component: UserListComponent }
]
}
];
export const APP_ROUTER_PROVIDERS = [
provideRouter(routes)
];
当我启动应用程序时,路由器重定向到 / users ,而 UserListComponent 工作正常。
我有两个问题:
答案 0 :(得分:1)
如果您导航相对路径,则需要传递relativeTo
参数:
this.router.navigate(['./edit', 17], {relativeTo: this.currentActivatedRoute});