Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

AngularJS - Redirect to another domain from code

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.com"; is working but $location.absUrl service from AngularJS default is not working.

like image 711
Arnab Das Avatar asked Aug 21 '13 08:08

Arnab Das


2 Answers

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.com'
like image 102
Alexis N-o Avatar answered Sep 27 '22 20:09

Alexis N-o


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

like image 20
Xiu Avatar answered Sep 27 '22 20:09

Xiu