【发布时间】:2020-01-01 16:49:16
【问题描述】:
我正在尝试通过单击图标导航到新页面,下面是代码
this.prj = e.data.project_number;
this.router.navigateByUrl('/dashboard/ProjectShipment/634');
我必须将this.prj 传递给它,而不是这个硬编码的查询参数000634。我的路径如下所示
const appRoutes: Routes = [
{
path: 'dB',
data: { title: 'Dashboard' },
children: [
{
path: 'ProjectShipment/:reportProject',
component: ProjectShipmentComponent,
data: { title: 'Project Shipment' },
}
【问题讨论】:
-
我认为您在谈论 PATH 参数,而不是 QUERY 参数。如果您尝试传递路径参数,MuruGan 的答案是正确的,并且 url 看起来像“/dashboard/ProjectShipment/634”。但如果我们谈论的是查询参数,那么 Miguel Pinto 的答案是正确的,并且 url 看起来像 '/dashboard/ProjectShipment?prj=634'
标签: javascript angular typescript angular7 angular-routing