A
A
Alena Djukic2016-05-26 18:39:47
Angular
Alena Djukic, 2016-05-26 18:39:47

Difference between module definitions in AngularJS?

Hello. I read the styleguide on AJS and it says there that you need to define the module and its dependencies as follows:

// ./app.modules.js
angular.module("someModule", []);

// ./some/someCtrl.js
angular.module("someModule").controller("generalCtrl", ["$scope", function($scope) {
  // code
}]);

But it so happened that I got into the habit of doing it like this:
// ./app.modules.js
var someModule = angular.module("someModule", []);

// ./some/someCtrl.js
someModule.controller("generalCtrl", ["$scope", function($scope) {
  // code
}]);

What is the difference between these two methods and which one is better to use?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question