How do I extract query parameters using ui-router for AngularJS?
In AngularJS' own $location
service I did:
($location.search()).uid
to extract the parameter uid from a URL. What is the corresponding code for ui-router?
Unless you're binding to the query parameters (see the documentation), you don't access them directly through $state
or $stateParams
. Use the $location
service.
EDIT: Per the docs, if you want to capture query parameters in $stateParams
, you can append a ?
to your url
, and name each query parameter, separated by &
, i.e. url: "/foo?bar&baz"
.