我的对象如下:
const navigationExtras: NavigationExtras = {
queryParams: {
serviceName: 'someName',
serviceId: 5,
businessAreaId: 1,
servicePhaseVersionId: 5,
versionDescription: 'Version 1',
phaseName: 'SomePhase',
mode: 1
我在下面航行:
this.router.navigate(['someUrl/'], navigationExtras);
在浏览器中导航后,我看到URl是这样的:
http://localhost:4000/someUrl/version?serviceName=someName&serviceId=5&businessAreaId=1&servicePhaseVersionId=5&versionDescription=Version%201&phaseName=SomePhase&mode=1
是否有可能使用浏览器的URL或以下参数获取字符串?
'serviceName=someName&serviceId=5&businessAreaId=1&servicePhaseVersionId=5&versionDescription=Version%201&phaseName=SomePhase&mode=1'
答案 0 :(得分:0)
使用参数
注入依赖项:
由于params返回一个Observable,你需要订阅它以获取参数。
constructor(private _activateRoute: ActivatedRoute) {
this._activateRoute.params.subscribe((params) => this.activateComponent(params));
}