ui-router icon indicating copy to clipboard operation
ui-router copied to clipboard

Dynamic params and query params, url not updated?

Open Ben305 opened this issue 10 years ago • 6 comments

Hi there, I'm using version 1.0.0-alpha.4 because I have the following use case:

I have to implement a search, and the parameters are passed via query params like this: /search?city=Boston&start=2016-01-01&end=2016-01-10

The state is defined like this:

$stateProvider.state('search', {
    url: '/search?city&startDate&endDate',
    templateUrl: 'some/url/template.html',  
    params: {
        city: {
             value: 'Boston'
         dynamic: true
    },
    startDate: {
         value: '2016-01-01',
        dynamic: true
    },
    endDate: {
        value: '2016-01-10',
        dynamic: true
    }
}

Everything is working well, and when the user updates the parameters, I'm calling $state.go($state.current.name, newStateParams);, and the callback function uiOnParamsChanged is also called correctly.

Only the parameters in the url are not updated. So when the user wants to search in Chicago, the url is still search?city=Boston... after the state-change. Is this the correct behavior? Do I have to update the url manually?

Ben305 avatar Apr 24 '16 12:04 Ben305

No you shouldn't need to manually update the URL. This sounds like a bug.

christopherthielen avatar Apr 25 '16 03:04 christopherthielen

Hi, I have a similar issue. My define:

$stateProvider.state('zone', {
    url: '/zone-:zoneId',
    templateUrl: '/zone-detail.html',
    controller: 'zoneController'
});

When I click on link on view (use ui-sref) or use $state.go, it redirect success. But when I change the zoneId on address bar -> state not change. The back button not work, too.

Test on Chrome.

Is this a bug?

dracula92107 avatar Apr 28 '16 11:04 dracula92107

@christopherthielen wonder this is related to https://github.com/angular-ui/ui-router/issues/2723

samithaf avatar May 02 '16 10:05 samithaf

@Ben305 Here is a working plunker: http://plnkr.co/edit/0ww2TBT2WNPkZauuvEjT?p=preview

Can you provide additional information? The URL should be updating.

@dracula92107 I think you have a different problem, but you haven't provided enough information to give an answer.

Can you open a new issue, and provide a plunker that reproduces the error? Start here: http://bit.ly/UIR-Plunk

christopherthielen avatar May 07 '16 21:05 christopherthielen

moving to alpha.6 milestone while waiting for info from @Ben305

christopherthielen avatar May 12 '16 21:05 christopherthielen

Closing due to no activity

christopherthielen avatar Jun 26 '16 03:06 christopherthielen