ng-table not working for dynamic data

后端 未结 6 1910
爱一瞬间的悲伤
爱一瞬间的悲伤 2020-12-03 23:53

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 h

6条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-12-04 00:24

    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.

提交回复
热议问题