How to redirect user to an absolute url in angularjs.
For example: i have a page, my current url (http://example.com/submit), once the user click some button in th
You need to use the browser level API, with the object window
, or you can inject the $window
reference in your controller.
window.location.href="http://www.google.com";
$window.location.href="http://www.google.com";
References:
window
$window
Best solution should be perform redirect in your $routeProvider
configuration, injecting the $window
object and performing all redirection you need.
I had some issues with the above solutions and came across this and thought I would share. Be sure to inject '$timeout', '$window' into your controller.
$timeout(function() {
$window.location.assign('https://URL');
}, 3000);
What about simple window.location.href = "http://google.com"
?
you can use window.location.href=""
and in between your quotes you can place your respective url