How do I navigate to a parent route from a child route?

前端 未结 11 1992
Happy的楠姐
Happy的楠姐 2020-11-29 19:04

My problem is quite classic. I have a private part of an application which is behind a login form. When the login is successful, it goes to a child route for th

11条回答
  •  抹茶落季
    2020-11-29 19:13

    Another way could be like this

    this._router.navigateByUrl(this._router.url.substr(0, this._router.url.lastIndexOf('/'))); // go to parent URL
    

    and here is the constructor

    constructor(
        private _activatedRoute: ActivatedRoute,
        private _router: Router
      ) { }
    

提交回复
热议问题