SoftTimur
SoftTimur

Reputation: 5540

Two query parameters in a url

Previously, I have defined a state of ui-router which has connected as parameter:

    .state('addinEdit', {
        url: '/addin/edit/{id}?connected',
        resolve: {
            test: [$stateParams, function($stateParams) {
                console.log($statePrams.connected)
            }]
        }
    }

As a result, I could call in a html:

   <a href="addin/edit/?connected=true" target="_self">New</a>

Now, I want to add another query parameter ifi in the url, I tried

    .state('addinEdit', {
        url: '/addin/edit/{id}?connected?ifi',
        resolve: {
            test: [$stateParams, function($stateParams) {
                console.log($statePrams.connected)
                console.log($statePrams.ifi)
            }]
        }
    }

But <a href="addin/edit/?connected=true?ifi=true" target="_self">New</a> does not seem to work.

When I see the url in a browser, it is https://localhost:3000/1/#/addin/edit/?connected=true%3Fifi%3Dtrue.

Does anyone know how to fix this?

Upvotes: 0

Views: 187

Answers (2)

RustyPiranha
RustyPiranha

Reputation: 896

you would use an & rather than another ?:

'/addin/edit/{id}?connected&ifi',

Upvotes: 1

Marcel Gwerder
Marcel Gwerder

Reputation: 8520

You have to use & for additional params:

<a href="addin/edit/?connected=true&ifi=true" target="_self">New</a>

And the same in the route definition

 url: '/addin/edit/{id}?connected&ifi',

Upvotes: 2

Related Questions