Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angularjs/21.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript AngularJS-$watch之后的事件_Javascript_Angularjs_Angularjs Scope - Fatal编程技术网

Javascript AngularJS-$watch之后的事件

Javascript AngularJS-$watch之后的事件,javascript,angularjs,angularjs-scope,Javascript,Angularjs,Angularjs Scope,我不知道怎么做 但我有可拖动的物品,可以放在画布上的任何位置 每次更改此可拖动位置时,$scope.arrowDraggableDetail都会更新此可拖动位置的x和y位置,$scope.arrowDraggableDetail也会更新$watch .directive('arrowDraggable',['$timeout',function($timeout){ return function(scope, element, attr){ $timeout(function

我不知道怎么做

但我有可拖动的物品,可以放在画布上的任何位置

每次更改此可拖动位置时,
$scope.arrowDraggableDetail
都会更新此可拖动位置的x和y位置,
$scope.arrowDraggableDetail
也会更新$watch

.directive('arrowDraggable',['$timeout',function($timeout){

  return function(scope, element, attr){  
    $timeout(function(){
       scope.$watch('arrowDraggableDetail', function(newValue, oldValue) { 
          if(newValue ){
             ***CALLING API FOR UPDATE ***
          }
      }, true);
    });
  }

}])
我需要做的是保存可拖动文件的更新位置

我的问题是,每次拖动项目时,我都会多次调用api,因为
$scope.arrowDraggableDetail
值经常更改


谁能帮我一下这方面的最佳做法是什么?

我最近问了一个类似的问题。这项技术被称为去Bouncing,这是一种很好的方法,但angularjs是否有任何功能可以用于此?可能是