1

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

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

then:

function myCtrl($stateParams) {
    console.log($stateParams.my_param);
}

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 $state.go. Something like this:

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

1 Answer 1

2

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.

Sign up to request clarification or add additional context in comments.

2 Comments

perfect! And in the case if I have more than one parameter?
Got here: url: '/index/my_route?my_param&my_param2'. Thank you!!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.