重新加载页面缓存,然后转到新页面 [英] Reload a pages cache, then go to a new page

查看:132
本文介绍了重新加载页面缓存,然后转到新页面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

背景

我有一个棱角分明的应用程序.

I have an angular app.

我缓存了一些东西,除非我通过一个按钮调用$window.location.reload(true),然后用另一个按钮转到另一页(按下两次按钮,否则我似乎无法使用angularjs中的任何内容或使用$ window函数中的任何内容来清除它们) ):

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):

清除缓存重载代码

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

移动页面代码

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

OR

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

问题

问题是我不知道如何一次按下1个按钮.

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

问题

如何移动位置并同时重新加载整个窗口?

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

注意

这个问题与我以前的帖子有些相关: Angular重新加载窗口,然后进入新状态

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

其他尝试:

下面的代码有问题.它不会像我想要的那样重新加载缓存

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
  }

推荐答案

此代码可在重定向后启用完全重新加载.在进入新页面时运行.

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

第一次访问,URL不包含刷新",因此$window.location.href更改为包含刷新".但是不会重新加载页面.只有重新加载页面并清除缓存后的行.但是,重新加载仅在添加哈希之后发生.

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);
    }

这篇关于重新加载页面缓存,然后转到新页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆