Search code examples
angularroutesangular5angular6angular2-routing

angular router navigate then reload


So I want to reload the app after navigating to a specific route ..

I use router.navigate to navigate to certain route based on user role and that works fine but I have to reload the page after routing if coming from sign in page (not every time user opens that certain route) - and reloading here is to update page language depending on user's language

so what i tried to do is

  else if(this.sp.role === 'Admin') {
      console.log('ooo')
      this.router.navigate(['/admin/dashboard']); 
      this.window.location.reload();

but that reloads the sign in page


Solution

  • Simple

    this.router.navigate(['path/to'])
      .then(() => {
        window.location.reload();
      });