我正在构建类似网格的东西,需要在dom中移动单元格(指令)。
当我在DOM中移动元素时,我也想更新范围树。比方说,我从这样的事情开始:
<div with scope1>
<directive with scope2>
</div with scope1>
<div with scope3>
<directive with scope4>
</div with scope2>
当我将“带有scope2的指令”移动到“带有scope3的diw”时:
<div with scope1>
</div with scope1>
<div with scope3>
<directive with scope4>
<directive with scope2>
</div with scope2>
然后我的范围树没有更新。所以“带有scope2的指令”仍然将scope1作为其父级。
是否有可能以某种方式手动将“scope with scope2”的父范围设置为“div with scope3”而不是“div with scope1”。
THX!
答案 0 :(得分:1)
当你想要'模特'时,你正在考虑'DOM'
基本方法应该是:
Parents指令具有父模型,其中包含子项列表。对孩子们进行父模板ng-repeat
<my-child-directive ng-repeat="child in myModel.children"
将模型从父子列表移动到另一个子列表,DOM更新。等瞧。