Redirect using AngularJS

With an example of the not-working code, it will be easy to answer this question, but with this information the best that I can think is that you are calling the $location.path outside of the AngularJS digest.

Try doing this on the directive scope.$apply(function() { $location.path("/route"); });


Don't forget to inject $location into controller.


Assuming you're not using html5 routing, try $location.path("route"). This will redirect your browser to #/route which might be what you want.


If you need to redirect out of your angular application use $window.location. That was my case; hopefully someone will find it useful.