使用外部url(推荐url)注册时路由器导航不工作



我希望我的页面在用户成功注册后重定向到主页。

1( 当我使用下面的url时,它工作得很好。

http://localhost:4200/signup 

2( 但是当我使用一个带有推荐id的url时,如下面的

http://localhost:4200/referral/ONGMwyi1azt

它将再次重定向到

http://localhost:4200/signup

代码:

signUp() {
let params = {};
params["action"] = "addUser";
params["first_name"] = this.first_name;
params["last_name"] = this.last_name;
params["user_name"] = this.user_name;
params["email_id"] = this.email_id;    
params["password"] = sha256(this.password);

this._httpService.addUser(this.url, params).subscribe(resp => {
if (
resp["status"] === "User Registration Successful"      
) {     
// this._zone.run(() => this._router.navigate(["/home"]));
// setTimeout(() => this._router.navigate(["/home"]), 10);
this._router.navigate(["/home"]);  
}  
});
}

用户成功注册了,但没有重定向到主页

当一个案例有效而另一个案例失败时,这里的问题到底是什么?非常感谢。

1.Please check routing module as i have mentioned, referral id should pass through routing time.
import { NgModule } from '@angular/core';
import { RouterModule, Routes } from '@angular/router';
const routes: Routes = [
{
path: '',
component: ParentComponent,
children: [      
{ path: 'referral/:referralId', loadChildren: './Path/referral.module#ReferralModule' }
]
}
];
@NgModule({
imports: [RouterModule.forChild(routes)],
exports: [RouterModule]
})
export class ReferralRoutingModule {}
2.You can use the below code in Referral Component. 
constructor(private _route: ActivatedRoute)
ngOnInit() {
this.referralId = this._route.snapshot.params['referralId'];
}

最新更新