Created
November 5, 2015 09:24
-
-
Save ironboy/876421189a32292e3a4b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$scope.changeWatch = function(){ | |
// An alternative to Angular $scope.$watch | |
// that does not trigger on initial load | |
var | |
init = true, | |
args = [].slice.call(arguments), | |
listener = args[1]; | |
args[1] = function(){ | |
if(init){ | |
$timeout(function() { init = false; }); | |
return; | |
} | |
return listener.apply(this,arguments); | |
}; | |
$scope.$watch.apply($scope,args); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment