AngularJS / NG网 - 更新阵列拼接不更新UI [英] AngularJS/ng-grid - Updating array with splice doesn't updates UI

查看:304
本文介绍了AngularJS / NG网 - 更新阵列拼接不更新UI的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图更新的 NG网 与阵列拼接
 我有一个普拉克 这里

I am trying to update ng-grid with array splice. I have a plunk here.

Add按钮添加新行。更新按钮数组中更新的最后一个项目。

Add button adds new row. Update button updates last item in the array.


  1. 选择行和放大器; preSS更新按钮。什么都没发生。

  2. preSS添加按钮。现在,用户界面​​得到了新的元素和放大器更新;以及previously更新元件。

  3. 同样的行为被再次&放重复;试。

我试过 $范围。$适用。我得到:

错误:$已经在进行中适用

"Error: $apply already in progress"

我甚至通过把 $范围尝试。$应用的setTimeout 里面调用块。再次出现同样的错误!

I even tried by placing $scope.$apply block inside a setTimeout call. Again the same error!

任何指针!

谢谢!

推荐答案

这是因为在NG-网(错误地)数据$观察者的数据对象,以供参考比较,而不是对对象的平等。你可能会通过的数据$手表功能(行3128):

That's because data $watcher in ng-grid (incorrectly) compares the data object for reference, instead on object equality. You might remedy this by setting the third parameter to true in data $watch function (line 3128):

$scope.$parent.$watch(options.data, dataWatcher, true);

Plunker

这篇关于AngularJS / NG网 - 更新阵列拼接不更新UI的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆