Angular reload current route and reload the current template

Ok I found the solution provided by lgalfaso on Github (exact paste):

Templates are
cached, if a user does not have the permissions to be in a page, then
this check should be done before it reaches the controller or after,
within the controller, but not on the template retrieval

If this is the way you want to follow, then you need to remove the
template from the $templateCache before you call reload

So that worked for me because login template actually gets cached as the template the user was trying to access. So removing it and letting angular re-fetch the correct one for the current route worked like a charm.

var currentPageTemplate = $route.current.templateUrl;
$templateCache.remove(currentPageTemplate);
$route.reload();

Leave a Comment