How strict should I be on dependency injection using AngularJS? I am not 
sure what the general consensus on this is. But I have my main app module 
defined as follows:

var app = angular.module('app', [
    'ionic',
    'ngCordova',
    'app.core',
    'app.hub'
]);

app.core does not depend on anything, but I have a service set up on 
app.core called AppVersion:

angular.module('app.core')
    .service('AppVersion', function () {
        this.version = '12.5.322b';
    });

One of my controllers in app.hub uses the AppVersion service:

angular.module('app.hub')
    .controller('InitController', ['$scope', 'AppVersion', function 
($scope, AppVersion) {
        $scope.version = AppVersion.version;
    }]);

But the definition to app.hub has no dependencies declared:

angular.module('app.hub', []);

Should it? The reason I ask, is because the app module does have app.core 
declared as a dependency. So when the main app module is loaded, all 
sub-modules are beforehand. app depends on app.hub and app.core, so I have 
a guarantee that both modules are loaded when the main module loads.

AngularJS does not crash, and I receive no console.log messages. So it 
works, but I am wondering whether app.hub should be defined as follows:

angular.module('app.hub', [
    'app.core'
]);

Should EVERY module defined declare its direct dependencies, irregardless 
of other modules dependencies? If so, why?

-- 
You received this message because you are subscribed to the Google Groups 
"AngularJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.

Reply via email to