angular-ui / ui-router

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

Ability to specify dynamic parameters only for particular child state #3464

Closed ventralnet closed 4 years ago

ventralnet commented 7 years ago

Previously in ui-router sub v1.0 we had the ability to specify 'reloadOnSearch' to be false for states where we didn't want to trigger a state change when an stateParam was changed

In v1.0 dynamic parameters were introduced to provide this functionality. One situation this doesn't cover that reloadOnSearch did was where a parameter was defined on a parent state as regular non dynamic, but having a particular child state specify that parameter to be dynamic (and having all other child states use it as non dynamic)

ventralnet commented 7 years ago

I dug around, looked through the source code and I don't see a good way to do this directly. What I did if it helps anyone out is to make use of the uiOnParamsChanged event that is fired when parameters (even dynamic parameters change). So basically I made all of my parameters on my parent state dynamic then in my child state where I want to treat my parameter as dynamic I do

ctrl.uiOnParamsChanged = (newParams) => {
   // based on the new params, dull a full hard load of the view, else do a 'soft' load of some of the data
}
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.