【发布时间】:2019-07-24 01:21:36
【问题描述】:
使用 Angular,我有一个正在传递给我的应用程序的 URL,它具有定义页面上应该发生的事情的查询参数,就像路由一样。
例如
http://localhost/?r=error&m=errorMessage
http://localhost/?r=registered&id=1234
如果这是一条通常的路线,我会这样做
const routes: Routes = [
{ path: '', component:AnnouncementComponent},
{ path: 'error', component:ErrorComponent},
{ path: 'registered', component: RegisteredComponent },
];
是否可以使用某种参数作为路由选择器? 或者在我的 AnnounceComponent 中,我如何交换错误或注册的组件?
【问题讨论】:
-
我不认为你可以通过路由来做到这一点,但是有一种方法可以根据查询参数动态加载组件。
标签: angular routes angular2-routing