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

State params resetted to default values when navigation back / forth #3739

Closed rothsandro closed 4 years ago

rothsandro commented 5 years ago

This is a:

My version of UI-Router is: 2.0.2

Bug Report

Current Behavior:

There are two states, each state has a param with a default value.

  1. User is on state A
  2. User navigates to state B, a specific value for a param is passed
  3. State B will be shown with the specific value for the param
  4. User navigates back to state A (using browser back button)
  5. User navigates forth to state B (using browser forward button)

State B will be shown with the default value for the param.

Expected Behavior:

State B should have the specific value (passed in step 2), not the default value. Navigating should not just restore the state url but also all params (at least until the user reloads the page).

Link to stackblitz that reproduces the issue:

Simple demo: https://stackblitz.com/edit/angular-d2bya2

  1. Navigate from /hello (State A) to /hello2 (State B)
  2. Param "demo: lalala" will be passed
  3. Navigate back to /hello
  4. Navigate forward to /hello2
  5. The state param is now "demo: hello2" which is the default value

Please use the buttons of your browser, not the one provided by stackblitz (they seem to reload the whole app).

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.