AngularJS Destroy $scope listeners
In AngularJS each listener on any $scope must be destroyed manually. To do that, when you creates a listener it returns a function to destroy it.
destroyCallback = $rootScope.$on 'my:event', ->
console.log 'my code'
So you can destroy it when current $scope destroys
$scope.$on '$destroy', ->
# unbind listener 'my:event'
destroyCallback()
Written by Carlos Sanz García
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Events
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#