Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to retrieve search parameters in non-html5 mode

Tags:

angularjs

I need to get at the search parameters (those after the ?) not the hash parameters (those after the #). Problem is, $location.search() switches between them based on the html5Mode settings, which is not what I want.

Short of parsing the URL myself, is there any way to get Angular to disgorge this information?

like image 510
Michael Lorton Avatar asked Jul 25 '13 20:07

Michael Lorton


1 Answers

In non-HTML5 mode $location.search() only retrieve information after #, e.g.

For url:

http://google.com/dir?query=123#/route?a=456

$location.search() is {a: 456}

$location.hash() is "", because if you define non-HTML5 route, everything after # will become part of $location.path() thus hash is not picked up anymore.

like image 164
Daiwei Avatar answered Oct 02 '22 23:10

Daiwei