angularJS ui router 多視圖單獨刷新問題

場景:視圖層級以下git

  view1github

     --view11dom

     --view111mvvm

需求:view11的一個動做事後,單獨刷新view12ide

解決方式:修改層級設計ui

  view1this

     --view11設計

         --view111code

結論:ui router不支持同級別views單獨刷新, ui router 原則是經過state控制視圖,不要直接控制viewsrouter

這個設計和只能更新mvvm scope的變量,儘可能不要操做dom元素同樣,我的認爲是很2..........

個人場景view11並行的有不少view13 view14 view15 view16,每一個都有操做刷新view12, 

按state更新的話,路由要從新嵌套,每一個下面都要嵌套view111,麻煩的很。。。

 

https://stackoverflow.com/questions/37300612/how-to-reload-a-single-named-view-with-angular-ui-router

The answer is - hierarchy should be built from states, not via views.

You should really study the doc (which is pretty clear, short and easy to read)

And then maybe follow this:

Nested states or views for layout with leftbar in ui-router?

to see, that we can

  • reload any child state (and trigger its resolves) - without reloading its parent
  • be sure that all views inside of reloaded states are reloaded (each view controller is re-init)

So, the answer should be

split your hierarchy into state hierarchy, not view. Navigate to and among children to change the child views... while profit from parent stable views

Check the plunker here

相關文章
相關標籤/搜索