I have a service which creates a configuration object for an external component. One of the config properties is an optional function that gets called when some event (non angular) gets triggered.
e.g. { eventHandler:function(e) { ... } }
Inside this eventhandler I want to send a message to the current controller. I tried getting instance of $rootService but it doesn't know about $broadCast.
update : the code (simplified version, to keep code short)
app.service('componentService',['$rootScope',
function($rootScope) {
this.getConfig = function() {
return {
transition:true,
... // other config parameters
clickHandler:function(e) { // event called by external library, e = event args
$rootScope.$broadCast("myEvent",e.value);
};
};
return {
getConfig : this.getConfig
}
}]);