Skip to content

Instantly share code, notes, and snippets.

@dsdstudio
Created March 7, 2014 14:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dsdstudio/9412153 to your computer and use it in GitHub Desktop.
Save dsdstudio/9412153 to your computer and use it in GitHub Desktop.
앵귤러쓸때 watcher 들을 꼭 정리하자~
var watchers = [];
watchers.push($scope.$watch("currentTab", function(newer, older) {
$scope.routing = getRouting(newer);
}));
watchers.push($rootScope.$watch("SR.connected", function(connected) {
if ( connected ) $scope.watchAskingPriceWithMarketPrice();
}, true));
$scope.$on("$destroy", function(){
watchers.forEach(function(fn) { fn(); });
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment