From dc2e736e5793db53768c6f4bf0f121c33b3c6dce Mon Sep 17 00:00:00 2001 From: livelazily Date: Thu, 7 Jan 2016 11:40:04 +0800 Subject: [PATCH] `scope` does not has "off" function --- ng-sortable.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/ng-sortable.js b/ng-sortable.js index 87bdc58..2b667b9 100644 --- a/ng-sortable.js +++ b/ng-sortable.js @@ -71,6 +71,7 @@ options = angular.extend(scope.ngSortable || {}, ngSortableConfig), watchers = [], getSource = getSourceFactory(el, scope), + offDestroy, sortable ; @@ -127,7 +128,7 @@ } function _destroy() { - scope.$off('$destroy', _destroy); + offDestroy(); angular.forEach(watchers, function (/** Function */unwatch) { unwatch(); @@ -190,7 +191,7 @@ })); }); - scope.$on('$destroy', _destroy); + offDestroy = scope.$on('$destroy', _destroy); } }; }]);