aikutto
aikutto

Reputation: 592

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 http://example.com/#/login?ref=/path/to/redirect it works fine. But if I use

$location.path("/login?ref=/path/to/redirect");

url looks like

http://example.com/#/login%3Fref=/path/to/redirect

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

Upvotes: 21

Views: 16421

Answers (2)

pykiss
pykiss

Reputation: 1087

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'
$location.$$compose()

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

Upvotes: 0

Stepan Suvorov
Stepan Suvorov

Reputation: 26236

It should be

$location.path('/login').search('ref', '/path/to/redirect')

Upvotes: 47

Related Questions