0

I'm working on a project with angular 1.6.x and ui-router 1.0.x

I want to change the browser url without reloading states, to do so I tried this :

   $state.transitionTo($state.$current.name, {param1: "value"}, {
                location: true,
                inherit: true,
                relative: $state.$current,
                reload: false,
                //Seems to be deprecated...
                notify: false
            });

I just want to change the param1 value in url, but transitionTo reloads my current state and so destroy and re-create my controller.

I previously worked with ui-router 0.x and the notify parameter worked for that.

How can I do this with ui-router 1.0.x ?

Thank you !

2 Answers 2

1

The fact is I was not in the right direction !

To do so I have to define the parameter as a dynamic :

https://ui-router.github.io/ng1/docs/latest/interfaces/params.paramdeclaration.html#dynamic

Thanks to @Anber

Sign up to request clarification or add additional context in comments.

Comments

0

I think it is a bug (using ui-router 1.0.3).

Definition:

.state('app.order', {
        url: '/order/:id',
        params: { 
            id: { value: null }    // id is optional
        },
        .....

Tried all variants:

 some_id can either be an int or null

 $state.go('.', {
            id: some_id
        }, { location: true });

 $state.go('.', {
            id: some_id
        }, { location: "replace" });

 $state.go('.', {
            id: some_id
        }, { location: true, reload: false });

 $state.go('.', {
            id: some_id
        }, { location: "replace", reload: false });

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.