Mr. Felix Mr. Felix - 1 year ago 117
AngularJS Question

Angular ui-router pass parameter within the URL

I know I can pass parameters when changing pages like this:

$state.go('index.my_route', {my_param : value});


function myCtrl($stateParams) {

But I need this parameter at URL then I would like to know how can I pass it with the URL string and still calling
. Something like this:

$state.go('index.my_route?my_param=' + value);
> "http://localhost/#/index/my_route?my_param=123"

Answer Source

Your route should have url with query parameter.

.state('index.my_route', {
   url: '/index/my_route?my_param',

Now can call the state in the same way using $state.go with parameters.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download