Issue: managing multiple directives that interact with a service or factory to communicate and log actions with a server. Should I establish dependencies between them?
angular.module('someModule', [])
.directive('someDir', ['logger', function ( logger ) {
//...
}])
.service('logger', ['$http', function( $http ){
//...
}]);
or should I opt for event-based relationships?
angular.module('someModule', [])
.directive('someDir', ['$rootScope', function ( $rootScope ) {
$rootScope.$emit('someEvent');
// ...
}])
.service('logger', ['$http', '$rootScope', function( $http, $rootScope ){
$rootScope.$on('someEvent', function(){
// ...
});
// ...
}]);
What are the advantages and disadvantages besides decoupling?