Problem with router.navigateByUrl and Reloading Page

My app uses a homepage that checks a file to see if the user has logged in already. If they have not, the user is sent to a sign-in page via a router.NavigateByUrl(…) call. After the user signs in, the sign-in page uses another router.nagivateByUrl(…) call to send them back to the homepage.

From my testing, it seems that the homepage is not reloaded when the user is sent back after signin in. It’s in the same state as when the app left that page to go to the sign-in page.

How can I force that page to reload?

disable view cache in your homepage router configuration

.state(‘home’, { cache: false, url : ‘/home’, templateUrl : ‘home.html’ })

What about using guards to handle the navigation for authorized and unauthorized users?

I’m using Angular routing, so all of my route code exists in the “app-routing.module.ts” file.

I’m not sure I see where to add “cache: false” in there?

It seems that my best fix here might be simply re-running my necessary functions within “ionViewDidLoad()”, unless there is a better approach?

1 Like