angular-ui / ui-router

The de-facto solution to flexible routing with nested views in AngularJS
http://ui-router.github.io/
MIT License
13.56k stars 3.01k forks source link

is there any way to set params dynamically, not param values but params as params ? #3705

Closed dharitdesai closed 4 years ago

dharitdesai commented 6 years ago

This issue tracker is for Bug Reports and Feature Requests only.

Please direct requests for help to StackOverflow. See http://bit.ly/UIR-SOF for details.

This is a (check one box):

My version of UI-Router is: (1.0.18)

General Query

Please direct general implementation questions to StackOverflow: http://stackoverflow.com/questions/ask?tags=angularjs,angular-ui-router

Please review the Sample Application which highlights common approaches: https://github.com/ui-router/sample-app-angularjs

(type general query here) Is there any way to set params dynamically, not param values but params as params ? In my case, I have a dynamic form comes from an api, and the fields in the form I want to be a param of the state, so that I don't have to reload whole state and just refresh the contents as we can do right now in dynamic: true in a param in state definition.

so for example

$stateProvider
.state('a', {
    url: '/abc',
    component: 'a',
    resolve: {
       filters: {//backend call for get the filter fields}
    })
.state('a.b', {
    url: '/search', 
    params: { //this object needs to be dynamic based on the filters i received in the parent state
     filter1 : {dynamic : true}, filter2: {dynamic:true}, filter3: {dynamic: true} ..... 
    }
    })
})
christopherthielen commented 6 years ago

This isn't currently possible. One feature that I'm interested in exploring (which would probably help with this) is a wildcard param on a state for query params. The API might be something like url: '/search?*'. For this to work, we'd have to add wildcard support in ui-router core. There are probably corner cases and gotchas, but I'm open to trying it. Unfortunately, I don't have as much time as I'd like to work on ui-router.

stale[bot] commented 4 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.

This does not mean that the issue is invalid. Valid issues may be reopened.

Thank you for your contributions.