最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - AngularJS - Redirect to another domain from code - Stack Overflow

programmeradmin3浏览0评论

I've set up one plunker to describe my problem: 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 = ""; is working but $location.absUrl service from AngularJS default is not working.

I've set up one plunker to describe my problem: 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."; is working but $location.absUrl service from AngularJS default is not working.

Share Improve this question edited Aug 21, 2013 at 8:35 Arnab Das asked Aug 21, 2013 at 8:13 Arnab DasArnab Das 3,7288 gold badges32 silver badges43 bronze badges
Add a ment  | 

3 Answers 3

Reset to default 8

The $location service does not allow to reload the page. The Angular way to perform a redirection to another domain is to use the $window service:

$window.location.href = 'http://google.'

Unfortunately, the $location service allow you only to change the relative path of your web application whether you want to be redirected to another site you have to use window.location.href

You not not defined ng-app on you html. And also not wired up your controller on html. See updated fiddle here

http://plnkr.co/edit/pPJcWtLrbQOHDT5mXleK?p=preview

发布评论

评论列表(0)

  1. 暂无评论