我在Angular 2應用程序上有這樣的組件,但它沒有在Angular 4上運行,RouteSegment不起作用。如何在Angular 4上做到這一點?routerOnActivate on Angular 4
export class CallBackLoginComponent {
private user: User = new User();
private showLoading: boolean = false;
private errorMessage: string = null;
constructor(private _loginService: LoginService,
private _router: Router,
private userService: UserService,
private _comunication: Comunication,
private _routerParams: RouteSegment) {
};
//Parametros recebidos atraves da rota /user/token
routerOnActivate(curr: RouteSegment) {
var token = {token: curr.getParam('token')};
if (token != null) {
this.showLoading = true;
this.errorMessage = null;
this.userService.vldToken(token).subscribe(
result => this.onLoginResult(result),
error => this.onLoginError(error)
);
}
else{
this._router.navigate(['/']);
}
}
a2.hubwiz.com/docs/ts/latest/api/router/OnActivate-interface.html做發佈 – Sreemat
這看起來更像角2預發佈之前,一些搜索?如果是這樣,路由器會在Angular 2的預發佈/ beta/rc和它的發佈版本之間進行更改。我不相信在Angular 4中這一切都發生了變化。 – DeborahK
是的,它是Angular 2的一個預發售版 – Undercrazy