'use strict'; (function(){ angular.module('app') .factory('MyController', MyController); MyController.$inject = [ '$scope', 'myService' ]; function MyController($scope, myService){ //-- subscribe on myService's events myService.on("myValueChanged", _onNewValue); //-- when the scope is destroyed, remove listener $scope.$on('$destroy', function () { myService.removeListener("myValueChanged", _onNewValue); }); /** * @private * * Called whenever myService emits "myValueChanged" event */ function _onNewValue (newValue) { console.log('new value:', newValue); } } }());