我正在使用 angular 2 RC 3 and router 3.0.0-alpha.8 并尝试导航到我使用 PathLocationStrategy 的另一个UI组件,但它只更新网址而不是UI
export const HomeRoutes: RouterConfig = [
{path:'search/:searchId',component:SearchListingComponent} ]
在我的headerComponent里面我有这个方法
goToSearch(searchId: string): void{
this.location.go('/search',searchId);}
它应导航到搜索列表页面,但它只更新网址 .
home.routes.ts文件:
export const HomeRoutes: RouterConfig = [
{ path: '', component: HomeComponent },
{ path: 'home', component: HomeComponent },
{ path: 'search', component: SearchComponent },
{path:'search/:searchId',component:SearchListingComponent},
{ path: 'listing/:id', component: ListingPageComponent}
]
app.routes.ts文件:
export const routes: RouterConfig = [
...HomeRoutes,
...UserRoutes,
...ProfileRoutes,
...LandownerRoutes
];
export const APP_ROUTER_PROVIDERS = [
provideRouter(routes),
AUTH_PROVIDERS
];
1 回答
您应该使用路由器进行导航