-
Notifications
You must be signed in to change notification settings - Fork 8
Open
Description
On the off-chance someone is using this more than once in the page, this adds more $watch functions than it needs. Only one is necessary, and only a single change detection can trigger the diff. Near simultaneous changes to left and right would otherwise create separate digest cycles.
Newer angular standards/preferences would suggest binding left and right to the controller, but for the sake of the current code, here's all that's needed.
var _this = this;
var unbindWatch = $scope.$watch(function () {
return { left: $scope.left, right: $scope.right };
}, function (newValue, oldValue, localScope) {
_this.doDiff();
}, true);
$scope.$on("$destroy", unbindWatch);Metadata
Metadata
Assignees
Labels
No labels