Skip to content

Instantly share code, notes, and snippets.

@ironboy
Created November 5, 2015 09:24
Show Gist options
  • Save ironboy/876421189a32292e3a4b to your computer and use it in GitHub Desktop.
Save ironboy/876421189a32292e3a4b to your computer and use it in GitHub Desktop.
$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