[英]AngularJS - Redirect to another domain from code
I've set up one plunker to describe my problem: Plnkr 我已经设置了一个来描述我的问题: Plnkr
Actually I want to navigate to another page in another domain (added one handler to a button click). 实际上我想导航到另一个域中的另一个页面(为按钮单击添加了一个处理程序)。 But it's not working.
但它不起作用。
Thanks in advance. 提前致谢。
Update 更新
window.location.href = "http://google.com";
is working but $location.absUrl
service from AngularJS default is not working. 正在工作但是来自AngularJS的
$location.absUrl
服务默认不起作用。
The $location
service does not allow to reload the page. $location
服务不允许重新加载页面。 The Angular way to perform a redirection to another domain is to use the $window
service : 执行重定向到另一个域的Angular方法是使用
$window
服务 :
$window.location.href = 'http://google.com'
不幸的是,$ location服务只允许您更改Web应用程序的相对路径,无论您是否要将其重定向到您必须使用的另一个站点window.location.href
You not not defined ng-app
on you html. 你没有在你的HTML上定义
ng-app
。 And also not wired up your controller on html. 并且还没有在html上连接你的控制器。 See updated fiddle here
在这里看到更新的小提琴
http://plnkr.co/edit/pPJcWtLrbQOHDT5mXleK?p=preview http://plnkr.co/edit/pPJcWtLrbQOHDT5mXleK?p=preview
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.