1

I have ui-router set up as follows

.state('root.event', {
    url : '/event/:id',
    templateUrl : 'templates/event.html'
})

(the controller is initiated in the template)

which gives nice looking Basic URL Parameters like:
www.mysite.com/event/1234

When a user navigates directly to my www.mysite.com/event path (ie param is missing) the template controller looks the most recent id parameter from either:
- a js variable stored in a value
- localstorage / cookie etc

I then return this to my state using $location.search('id', 1234)

...however, this results in URLs which have Query URL Parameters like:
www.mysite.com/event/?id=1234

Is there a technique to ensure that $stateparams updates present the url in basic format on update ?

...or is it possible to get the URL parameter & update the $state before the state change ?
(I looked at Resolve but this seems mostly to be about passing parameters to controllers)

I've had a look here, here and here - but most of the questions relate to how to avoid reload on update of $state params

1 Answer 1

1

$location.search does exactly that. It adds query URL parameter. I think what you're looking for is

$state.go('root.event', {id: 1234})
Sign up to request clarification or add additional context in comments.

1 Comment

won't that reload the template rather than just updating the parameters ?

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.