angularJS ui router 多视图单独刷新问题
场景:视图层级如下
view1
--view11
--view111
需求:view11的一个动作过后,单独刷新view12
解决方式:修改层级设计
view1
--view11
--view111
结论:ui router不支持同级别views单独刷新, ui router 原则是通过state控制视图,不要直接控制views
这个设计和只能更新mvvm scope的变量,尽量不要操作dom元素一样,个人认为是很2..........
我的场景view11并行的有很多view13 view14 view15 view16,每个都有操作刷新view12,
按state更新的话,路由要重新嵌套,每个下面都要嵌套view111,麻烦的很。。。
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