0

I want to go back to my parent componentn after a form is submitted in my AddUserComponent.

My url should change : /video/1/user to /video/1

I tried

this._router.navigate(['../../video'],{ relativeTo: this.route })
this._router.navigate(['../../video',{video_id:1}],{ relativeTo: this.route })

but it's not working.

My routes :

export const routes = [
  { path: '', component: VideosComponent },
  {
    path: 'video/:video_id',
    children :[
        { path: '', component: VideoComponent },
        { 
          path: 'user',
          children :[
              { path: '', component: AddUserComponent },
              { path: ':user_id', 
                children :[
                  { path: '', component: EditUserComponent}
                ]
              }
          ]
        },
    ]
}
];

Any ideas ?

Adrien Castagliola
  • 911
  • 2
  • 11
  • 30

2 Answers2

0

These should work

this._router.navigate(['../../video',1],{ relativeTo: this.route })
this._router.navigate(['../../video/' + 1],{ relativeTo: this.route })
this._router.navigate(['../../video/1'],{ relativeTo: this.route })

or absolute

this._router.navigate(['/video',1])
Günter Zöchbauer
  • 623,577
  • 216
  • 2,003
  • 1,567
0

Using navigateByUrl

this._router.navigateByUrl("/video/1");
Michael
  • 1,692
  • 1
  • 17
  • 19