AngularJS ui-router $state.go('^') only changing URL in address bar, but not loa

公司前端采用的AngularJS框架,在做订单保存跳转到列表页面的时候,由于按钮加了权限(权限框架采用的是shiro),造成了跳转到列表页面,按钮不显示的问题。只有手动刷新,按钮才会出现,问了公司的前端工程师,由于$state.go(xxx)默认只改变地址栏的地址,而不会向后台真正发送请求。造成了不会走权限拦截器,拿不到这个人的权限资源。

解决方案方案一

在需要做页面跳转的地方,放上如下代码:

 var storage = window.localStorage;
  
   storage.setItem("hasRefresh",1)

 在列表页面,也就是被跳转到的地方,放上如下代码:

var storage = window.localStorage;
  
    hasRefresh = JSON.parse(storage.getItem("hasRefresh"));
    if (!!hasRefresh) {
      storage.removeItem("hasRefresh");
      location.reload();
    }

 可以解决这个问题。

解决方案二

请参照:http://stackoverflow.com/questions/21309366/angularjs-ui-router-state-go-only-changing-url-in-address-bar-but-not-loa

猜你喜欢

转载自newboy2004.iteye.com/blog/2264194