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
  • 881
  • 2
  • 9
  • 29

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
  • 558,509
  • 191
  • 1,911
  • 1,506
0

Using navigateByUrl

this._router.navigateByUrl("/video/1");
Michael
  • 1,602
  • 1
  • 17
  • 18