How to use Querystring with $location.path() in AngularJS


I want to redirect user to another page after successful login using query string. If I copy & paste to browser's address bar it works fine. But if I use


url looks like

How can I decode %3F to '?' ? Thanks

Problem courtesy of: aikutto


It should be

$location.path('/login').search('ref', '/path/to/redirect')
Solution courtesy of: Stepan Suvorov


I had the same problem.

I want to change path and search the same time.

It is possible by doing this:

$location.$$search ={foo:'bar', buz:'buz'}
$location.$$path = '/some/path'

It is not documented and it could broke at any new angular version.

Discussion courtesy of: pykiss

This recipe can be found in it's original form on Stack Over Flow.