NG-表不工作的动态数据 [英] ng-table not working for dynamic data

查看:132
本文介绍了NG-表不工作的动态数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建了一个表,我使用HTTP来加载表中的数据。因此,在每一次点击,我的表中的数据是变化的,但我没有看到表中更新的数据。
我创建了一个示例 Plunker 为参考。在我的项目,当我点击刷新新的数据,在表中的数据得到的改变,但2-3后,点击它不会改变。有没有人知道,如何解决它。

I have created a table and I am using http to load the data in the tables. So, in every click, my table data is changing, but I don't see the updated data in the table. I had created a sample Plunker for the reference. In my project, WHen I click on Reload New Data, the data in table get's changed, but after 2-3 click it doesn't change. DId anyone know, how to fix it..

推荐答案

它与ngTable指令的​​一个问题。它更新,只有当 data.length 的变化。看看这个普拉克。我设置$范围['tableParams1']为null, $超时内我设置了​​新的数据。这迫使angularJs做一个新的周期。因此在第一次循环的ngTable看到data.length变为0,并在新的周期的ngTable看到data.length再次改变。如果你不使用$超时,则ngTable将看到data.length仍然和以前一样,不会做任何事。

It is a problem with the ngTable directive. It updates only when data.length changes. Take a look at this plunk. I set $scope['tableParams1'] to null and inside the $timeout I set the new data. This forces angularJs to do a new cycle. So in the first cycle the ngTable sees the data.length changed to 0 and in the new cycle the ngTable sees the data.length changed again. If you don't use the $timeout, the ngTable will see that the data.length remains the same as before and won't do nothing.

这篇关于NG-表不工作的动态数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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