[英]from two way data binding to one way databinding angularjs
I have this directive 我有这个指令
<directive dataset="dataObject"></directive>
my directive link function have something like this: 我的指令链接函数有这样的东西:
var oldData = '';
var initFunction = function(){
oldData = scope.dataObject;
}
scope.reset = function(){
scope.dataObject = oldData;
};
The problem is that when i modify the data in some way, when i want to reset the dataobject to its default value before modifying but everytime i do this, the two way databinding its messing my data, now the problem is that this is for a plot so the data is modified all the time 问题是,当我以某种方式修改数据时,当我想在修改之前将数据对象重置为其默认值时,每次执行此操作时,都会用两种方式对数据进行绑定以使我的数据混乱,现在的问题是这是为了进行绘制,以便始终修改数据
Use angular.copy
to create "other reference" 使用angular.copy
创建“其他参考”
var initFunction = function(){
oldData = angular.copy(scope.dataObject);
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.