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?
How do I extract query parameters using ui-router for AngularJS? In AngularJS' own
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 EDIT: Per the docs, if you want to capture query parameters in |
|||||||||||||||||||||
|
See the query parameters section of the URL routing documentation.
For this example, if the url is
|
|||||||||||||||||||||
|
ui-router does not differentiate between different types of parameters in a url like the $location service does. In your controllers you can use the $stateParams service to get access to all the different types of parameters in your url. below is an example from the ui-router wiki:
So in your case to find the uid param simply use:
|
|||
|
You also need to define the query parameters in the $stateProvider e.g.
as explain by benfoster.io |
|||||||||
|