0

Using ui-router how can I accomplish the following URL change? For example, when a user goes to "/page?hello=True" I want the url to change to "/page?status=hello".

$stateProvider.state('page', {
   url: '/page/:id?status',
   controller: 'MyCtrl as myCtrl',
   templateProvider: function($templateCache) {
     return $templateCache.get('templates/route.html');
   }
 });
1
  • can use stateChangeStart event in ui-router to change the params of the url. Commented Jan 26, 2016 at 22:43

1 Answer 1

1

You can use the stateChangeStart event in the app.run method to listen for state changes into that route, and change anything you want on the params. Something like this, might need to play with toState and toParams to get it right for you...

.run(['$state', '$rootScope', function($state, $rootScope) {
    $rootScope.$on('$stateChangeStart', function(e, toState, toParams, fromState, fromParams) {

        if (toState.name === 'invitation') {
            //change toParams to whatever you want 
        }
    });
});
Sign up to request clarification or add additional context in comments.

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.