Issue
After creating the account, I want to retrieve the ID of the account created through a route but I receive the following error: NG04002: Cannot match any routes. URL Segment: 'register-next'
The code
Register.ts
async postClient(){
if(this.form.valid){
const l = await this.load.create({
message:'Enregistrement en cours...',
spinner:'dots',
})
l.present();
if(this.form.value.password === this.form.value.password_){
this.clientService.registerClient(this.form.value).subscribe(res =>{
if(res){
l.dismiss();
let id = res['id'];
this.route.navigateByUrl('/register-next',id);
}else{
this.alertErreur();
}
});
}else{
l.dismiss();
this.alertErreurPassword();
}
}else{
this.alertErreur();
}
}
app.routing.ts
{
path: 'register-next/:id',
loadChildren: () => import('./pages/register-next/register-next.module').then( m => m.RegisterNextPageModule)
},
Register-next.ts
this.id = this.router.snapshot.params['id'];
Solution
Try this:
let id = res['id'];
this.route.navigateByUrl(`/register-next/${id}`);
Answered By - Hamza
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.