christopherthielen / ui-router-extras

THIS PROJECT IS NO LONGER MAINTAINED -- Extras for UI-Router for AngularJS. Sticky States (a.k.a. parallel states), Deep State Redirect (for tab-like navigation), Future States (async state definition)
http://christopherthielen.github.io/ui-router-extras/
MIT License
917 stars 211 forks source link

Refresh sticky states without reload when parent states' params change #311

Closed sercangurbuz closed 8 years ago

sercangurbuz commented 8 years ago

Similiar question have been asked but didnt find a solution for the following case. States i have

main
main.product/:id - params {id : 'new'}
main.product.info - sticky
main.product.comments - sticky

Let say,there is a crud form in product state. Initially sticky tabs works nice,however Id param changes to some identity number without reload after save.

$state.go('main.product',{id:[identity]},{notify:false,reload:false});

Then changing the sticky states cause the whole reload initializing respectively main.product main.product.info - say this is the previous state main.product.comments - say this is the current state

Any workaround to keep sticky states works without reloading parent state ?

plunker :https://plnkr.co/edit/null7bfYhARa5v0Lu9mD?p=info

christopherthielen commented 8 years ago

The DOM, $scope, and controller of a Sticky State (and all activated substates) are retained until one of two things happen:

  • The parent of the sticky state is exited
  • The parent of the sticky state is directly activated

When a parameter value changes, ui-router exits and re-enters a state. This means the parent main.product is exited and entered, thus causing the sticky state to reload too.


Any workaround to keep sticky states works without reloading parent state ?

I don't think it's possible without rearranging your state definitions.

For instance, you could move your main.product logic into a child state main.product.view that has the parameter :id.