AngularJS - 我该怎么做一个完整的页面加载一个重定向? [英] AngularJS - How can I do a redirect with a full page load?

查看:90
本文介绍了AngularJS - 我该怎么做一个完整的页面加载一个重定向?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我希望做一个重定向,做一个完整的页面重载这样从我的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 =htt​​p://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屋!

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