Angularjs 取消绑定到datagrid单元格的对话框时,如何还原绑定的数据

Angularjs 取消绑定到datagrid单元格的对话框时,如何还原绑定的数据,angularjs,angular-ui-grid,Angularjs,Angular Ui Grid,我使用angular与angular用户界面网格和angular模式服务+引导 我的ui网格中的数据也绑定到我的对话框,当用户双击datagrid的单元格时,该对话框打开 当用户在对话框中更改数据时,它在datagrid中也会更改 当用户决定取消对话框时,编辑的数据保留在单元格中 多亏了数据绑定 angularJS中是否有任何功能可以让我更好地控制数据绑定何时开始/结束或如何拦截它?一种常见的方法(Angular1.3之前)是在将对象传递到对话框之前复制对象。当用户保存编辑时,将替换原始文件和已

我使用angular与angular用户界面网格和angular模式服务+引导

我的ui网格中的数据也绑定到我的对话框,当用户双击datagrid的单元格时,该对话框打开

当用户在对话框中更改数据时,它在datagrid中也会更改

当用户决定取消对话框时,编辑的数据保留在单元格中

多亏了数据绑定

angularJS中是否有任何功能可以让我更好地控制数据绑定何时开始/结束或如何拦截它?

一种常见的方法(Angular1.3之前)是在将对象传递到对话框之前复制对象。当用户保存编辑时,将替换原始文件和已编辑的副本

在Angular 1.3中,他们添加了该选项,使您能够更好地控制模型值的更新时间。使用ng模型时,它将数据存储在名为
viewValue
modelValue
的两个属性中

viewValue
是当前在输入/文本区域中键入的内容
modelValue
是绑定使用的实际值,如果用户输入的内容无效,则可能与
viewValue
不匹配

使用
ng model options
可以推迟更新模型值,直到发生某个事件。在这种情况下,您可以使用表单发送的“提交”事件延迟更新模型:

<form name="myForm" ng-model-options="{updateOn: 'submit'}" ng-submit="onFormSubmit()">
  <input type="text" name="myInput" ng-model="dialogData.value" />
  <button type="submit">Save</button>
  <button type="button" ng-click="cancelDialog()">Cancel</button>
</form>

$scope.onFormSubmit = function() {
  // do something then close dialog
  $scope.$close();
};

$scope.cancelDialog = function() {
  // cancel any pending updates to modelValue
  // not required in this example, but good practice
  $scope.myForm.$rollbackViewValue();
  $scope.$close();
}

拯救
取消
$scope.onFormSubmit=函数(){
//做点什么然后关闭对话框
$scope.$close();
};
$scope.cancelDialog=函数(){
//取消对modelValue的所有挂起更新
//本例中不要求,但良好实践
$scope.myForm.$rollbackViewValue();
$scope.$close();
}
链接到

这在扔掉表单的场景中非常有效(比如模态对话框中的表单)。但我在验证方面遇到了一些问题,我认为这只是一个角度错误,b/c提到使用它来重置表单