Sign up ×
Stack Overflow is a community of 4.7 million programmers, just like you, helping each other. Join them, it only takes a minute:

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

share|improve this question

1 Answer 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})
share|improve this answer
    
won't that reload the template rather than just updating the parameters ? – goredwards Jun 3 at 0:16

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.