【发布时间】:2018-05-26 23:57:36
【问题描述】:
在我的 Angular 4 项目中,我在路由上有一个容器组件:
const appRoutes: Routes = [
{ path: '', component: HomeComponent},
{ path: '404', component: NotfoundComponent},
{ path: 'pages/:page-handle', component: StaticpagesComponent },
{ path: 'blog/:blog-handle', component: StaticpagesComponent },
{ path: 'idx', component: ListingComponent },
{ path: 'area/:area-name', component: AreadetailComponent },
{ path: 'zip-code/:zip-name', component: ZipdetailComponent },
{ path: ':agent-handle', component:AgentComponent },
// otherwise redirect to home
{ path: '**', redirectTo: '404' }
];
所以我想在域名之后访问不同的组件 例如
http://localhost:8080/:zip-name 然后应该调用 ZipdetailComponent
http://localhost:8080/:area-name 然后应该调用 AreadetailComponent
http://localhost:8080/:page-handle 然后应该调用 静态页面组件
问题:域后的任何名称都会进入以下路径:
{ path: ':agent-handle', component:AgentComponent },
谁知道我该如何解决?
【问题讨论】:
-
您找到解决方案了吗?
标签: angularjs angular angular-ui-router angular4-router