创建严格用于外部重定向的路由的正确方法是什么,还要为其添加一些url参数?

在我的示例中,我想创建一个“/ Register”路由,首先以编程方式附加一些参数,然后重定向到注册/登录网站 .

这是流程:

1)用户点击电子邮件中的链接并点击角网站:“http://my.site.com/Register?token=1234

2)Angular站点做了一些工作并重定向到“http://login.site.com/Register?token=1234&extrainfo=4567

I know how to solve this, but it seems like a hack. That's because i'm using a component that i don't actually need. Would prefer to use a "service" of some sorts...

我正在创建一个实现CanActivate的组件 .

{ path: 'Register', component: RegisterRedirectComponent, canActivate: [RegisterRedirectComponent] },

 // actually a component, because we need to provide a component to routes

我实现了canactivate,它总是会返回false,因为它会事先进行重定向 .

import * as ng from '@angular/core';
import { CanActivate } from '@angular/router';

/*
This is a component trick so that we can implement a redirector using canactivate.
The routing path leads to this component, which is never reached, because canactivate is always false and forces a redirect.
Replace with better solution in future... this is a useless "Component".
*/

@ng.Component({
template: ''    
})
export class RegisterRedirectComponent implements CanActivate {
    constructor() {}

    canActivate() {
        // Get current url
        // Do some work to get extra parameters
        // Append to url
        window.location.href = // url
        return false;
    }
}