Angular.js:是否可以基于现有示波器数据重新渲染NG-重复? [英] Angular.js: Is it possible to re-render ng-repeats based on existing scope data?

查看:505
本文介绍了Angular.js:是否可以基于现有示波器数据重新渲染NG-重复?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一堆在我看来连 UL 列出了正在使用一个jQuery UI的:可排序的指令,以方便列表项的拖放和重新排序

I have a bunch of connected ul lists in my view which are using a jQuery UI: Sortable directive to facilitate drag and drop and reordering of the list items.

更改我通过jQuery UI的拖拽制造和使用 $适用功能下降我向 $范围,这部分作品...

Changes I make via jQuery UI's drag and drop I apply to the $scope using the $apply function, this part works…

我遇到然而现在的问题是,对落入某些列表的我提供了用户需要填写一个自定义窗体。

The issue I am running into now however is that on drop into some of these lists I provide a custom form that the user needs to fill out.

用户有权选择:


  1. 填写表格并继续,然后做了 $适用来电
    数据持续到 $范围

  2. 单击取消它,而不是调用按钮 $适用来存储信息,应恢复过去的拖/有效降互动重新呈现'我的所有名单,以反映这仍然是在 $范围在此阶段中的数据(因为最新的拖累还没有还没有什么影响)。

  1. fill out the form and continue which then does the $apply call to persists the data into the $scope
  2. click a cancel button which instead of calling the $apply to store info, should revert the last drag/drop interaction effectively 're-rendering' all my lists to reflect the data that is still in the $scope at this stage (since the latest drag had not had any effect on it yet).

这个取消按钮,有效地恢复所有用户之前的点的效果拿起列表项拖到另一个列表中。

The effect of this "cancel" button is effectively reverting everything to the point before the user picked up the list item and dragged it into another list.

我怎么能强制刷新或我的 NG-重复 s'的重新渲染,让他们直观地刷新,显示当前的 $范围数据再一次?

How can I force a 'refresh' or 're-render' of my ng-repeats so that they visually refresh and show the current $scope data again?

推荐答案

当用户开始填写表单,我会成立

When the user starts filling out the form, I would set

$ scope.oldData = angular.copy($ scope.data);

然后,使用形式,他喜欢让用户编辑$ scope.data。

Then let the user edit $scope.data using the form as he likes.

这时如果用户presses取消,只需设置 $ scope.data = $ scope.oldData

Then if the user presses cancel, just set $scope.data = $scope.oldData.

这篇关于Angular.js:是否可以基于现有示波器数据重新渲染NG-重复?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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