AngularJS - 如何使用整页加载进行重定向? [英] AngularJS - How can I do a redirect with a full page load?
问题描述
我想做一个重新加载整个页面的重定向,以便在页面加载时刷新来自我的 Web 服务器的 cookie.window.location = "/#/Next"
和 window.location.href = "/#/Next"
不起作用,它们做了一个 Angular 路由命中服务器.
I want to do a redirect that does a full page reload so that the cookies from my web server are refreshed when the page loads. window.location = "/#/Next"
and window.location.href = "/#/Next"
don't work, they do an Angular route which does not hit the server.
在 Angular 控制器中发出完整服务器请求的正确方法是什么?
What is the correct way to make a full server request within an Angular controller?
推荐答案
For <a>
tags:
You need to stick target="_self"
on your <a>
tag
AngularJS 将执行完整页面重新加载的三种情况:
There are three cases where AngularJS will perform a full page reload:
使用 JavaScript:
$location
服务只允许您更改 URL;它不允许您重新加载页面.当您需要更改 URL 并重新加载页面或导航到其他页面时,请使用较低级别的 API:$window.location.href
.
The $location
service allows you to change only the URL; it does not allow you to reload the page. When you need to change the URL and reload the page or navigate to a different page, please use a lower level API: $window.location.href
.
见:
这篇关于AngularJS - 如何使用整页加载进行重定向?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!