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

Provide finer control on state view reuse when changing url #3482

Closed sarod closed 4 years ago

sarod commented 7 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:

My version of UI-Router is: 1.0.3

Feature Request

ui-router 1.0 dynamic parameters allow some control over when the state and views are recreated. However in some cases one may need more control. ui-router 0.2 provided more flexibility thanks the notify:false option. However notify: false needed to be defined for each call to $state.go and were not usable in links ui-sref.

A more flexible approach would be to support registering an optional "reloadFn" function on the StateDeclaration. The routing would then call this method with the parameters of the previous state and the parameters of the new state. If the function returns true the view will be reused similarly to what is done currently when changing only dynamic params. If the function returns false the view will be recreated.

export interface StateDeclaration {    
    reloadFn?: ReloadStateFn;
}

export interface ReloadStateFn {
    (previousParams: {[key: string]: Param;}, newParams; {[key: string]: Param;}): boolean;
}
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.