1

Background

I have an angular app.

I have some stuff cached that I can't seem to clear with anything in angularjs or with anything in the $window function unless I call $window.location.reload(true) via a button, then go to another page with another button (2 button presses):

Clear Cache Reload Code

  $scope.reloadPage = function() {
    $window.location.reload(true)
  }

Move Pages Code

$state.go('actionWizard', { uuid: AUuid });

OR

var actionPage = "#!/action/"
actionPage = actionPage.concat(AUuid)
$window.location = actionPage

Problem

The problem is that I can't figure out how to have 1 button press do both at once.

Question

How do I move locations and do a full window reload at the same time?

NOTE

This question is somewhat related to my previous post: Angular reload window then go to a new state

Other Attempts:

This code below has a problem. It does not reload the cache like I want it to either

  $scope.movePage = function() {
    var actionPage = "#!/action/"
    actionPage = actionPage.concat(AUuid)
    actionPage = actionPage.concat('?eraseCache=true')
    console.log("ACTION PAGE: ")
    console.log(actionPage)
    $window.location = actionPage
  }
Rorschach
  • 3,684
  • 7
  • 33
  • 77

1 Answers1

0

This code enables a full reload after a redirect. It is run upon entering the new page.

First time through, the url does not contain 'refresh', so $window.location.href changes to contain 'refresh'. BUT this does not reload the page. Only the line after it reloads the page and clears the cache. But, the reload only happened after the hash was added.

So, I engaged in a full reload without an infinite loop that happens automatically upon entering the page

    var currentHref = $window.location.href
    if (!currentHref.includes("refresh")) {
        $window.location.href = $window.location.href + "#refresh"
        $window.location.reload(true);
    }
Rorschach
  • 3,684
  • 7
  • 33
  • 77