AngularJS - 我该怎么做一个完整的页面加载一个重定向? [英] AngularJS - How can I do a redirect with a full page load?
问题描述
我希望做一个重定向,做一个完整的页面重载这样从我的Web服务器的cookie被刷新页面加载时。 了window.location =/#/下一页
和 window.location.href =/#/下一页
唐'T的工作,他们不打服务器中角路由。
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.
什么是使一个角控制器内的整个服务器请求的正确方法是什么?
What is the correct way to make a full server request within an Angular controller?
推荐答案
对于< A>
代码
For <a>
tags:
您需要坚持目标=_自我
在&LT; A&GT;
标签
有三种情况下AngularJS将进行重新加载整个页面:
There are three cases where AngularJS will perform a full page reload:
- 包含目标元素结果链接
例如:&LT; A HREF =/转/链路A = B?TARGET =_自我&GT;链接&LT; / A&GT;
- 绝对链接,去到不同的域结果
例如:&LT; A HREF =http://angularjs.org/&GT;链接&LT; / A&GT;
- 以'/'链接,导致当基地被定义不同的基本路径结果
例如:&LT; A HREF =/不是我的基地/链接&GT;链接&LT; / A&GT;
- Links that contain target element
Example:<a href="/ext/link?a=b" target="_self">link</a>
- Absolute links that go to a different domain
Example:<a href="http://angularjs.org/">link</a>
- Links starting with '/' that lead to a different base path when base is defined
Example:<a href="/not-my-base/link">link</a>
使用JavaScript
的 $位置
服务让您只改变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屋!