After reviewing two AngularJS examples on Github, I find myself uncertain about how to properly modularize controllers. The first example sets a variable (foodMeApp) and reuses it, resulting in controllers that require fewer arguments and are easier to read. However, the second example does not use a variable (foodMeApp) and has more arguments, which seems to be a common approach in AngularJS samples.
Is there any advantage to using the second method?
1.https://github.com/IgorMinar/foodme
var foodMeApp = angular.module('foodMeApp', ['ngResource']);
foodMeApp.constant('CONFIG_A', {
baseUrl: '/databases/',
});
foodMeApp.controller('HogeController', function HogeController($scope, CONFIG_A) {
console.log(“less arguments");
});
2.https://github.com/angular-app/angular-app
angular.module('foodMeApp', ['ngResource']);
angular.module('foodMeApp').constant('CONFIG_B', {
baseUrl: '/databases/',
});
angular.module('foodMeApp').controller('HogeController', ['$scope', 'CONFIG_B', function($scope, CONFIG_B) {
console.log("more arguments");
}]);