Arnab Das
Arnab Das

Reputation: 3728

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.

Upvotes: 5

Views: 12385

Answers (3)

Alexis N-o
Alexis N-o

Reputation: 3993

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'

Upvotes: 8

Xiu
Xiu

Reputation: 125

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

Upvotes: 2

Chandermani
Chandermani

Reputation: 42669

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

Upvotes: 0

Related Questions