2

I am using the following method to redirect to the Item page and do a full page reload too. Works in all browsers, but Safari and IE (as always!). In those two, the current page gets reloaded.

Any recommendations on how to do it differently?

<a href="/items/{{item.$id}}" onclick="location.reload()" class="btn">Item</a>

I have also tried it in JS as follows, but the same problem occurs in Safari and IE

$scope.redirect = function(Item) {
     window.location.href = '/items/' + item.$id;
     window.location.reload(); 
}
towi_parallelism
  • 1,421
  • 1
  • 16
  • 38

2 Answers2

1

Try this:

$(document).ready(function(){
 // put all your js inside it
 init();
});

also try by disabling cache parameter

0

To do it the way that you are doing, you should use the angular $window rather than window while in an angular controller. A good example of reloading the route or the whole window is here: AngularJs: Reload page


Alternatively I would consider have a button on the page:

<button ng-click="goItem(item.$id)" class="btn">Item</button>

which calls the action on the controller with the id as a parameter:

$scope.goItem = function(id){
    $location.path('/items/' + id );
};

and redirects to the specific item route.

Matt D
  • 3,289
  • 1
  • 15
  • 29
  • thanks Matt, but `$location.path` would not do the reload for me. how about that part? also, the problem in Safari and IE is not that the page is not reloaded. It's that instead of the new redirected page, the previous one gets reloaded – towi_parallelism Jul 04 '18 at 09:32