I'm trying to do the following:
eventService.emit = function(name, optionalArg1, optionalArg2,... ){
$rootScope.$broadcast(name, optionalArg1, optionalArg2,...);
};
with an unlimited number of optional arguments. (broadcast "definition": $broadcast(string, args...))
I thought
eventService.emit =$rootScope.$broadcast;
would work but it doesn't($broadcast function may access to $rootscope attributes) and
eventService.emit = function(){
$rootScope.$broadcast(arguments);
};
doesn't seem to work
Thanks for the help
original code:
services.factory('eventService', function($rootScope, $http){
var eventObject = {};
eventObject.emit = function(name){
$rootScope.$broadcast(name);
};
return eventObject;
});
typeofoperator to see if a variable is defined