3

How i can go to a state and add query params to the url at the same time? Lets say i have this state:

$stateProvider
           .state('cart', {
            templateUrl: 'client/cart/cart.html',
            url: '/my-cart',           
            controller: 'CartController'
        })

I want from some views to $state.go('cart') and from some views to $state.go('cart') but with query params added to it like, /cart?purchase=complete

2 Answers 2

1

So i found the answer, i hope it will help for someone else.

$stateProvider
           .state('cart', {
            templateUrl: 'client/cart/cart.html',
            url: '/my-cart?purchase',           
            controller: 'CartController'
        });

And then:

$state.go('cart', {'purchase': 'complete'});

The results will be:

my-cart?purchase=complete
Sign up to request clarification or add additional context in comments.

Comments

0

try this

$state.go('cart', {'purchase': 'complete'});

Comments

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.