Skip to content

Instantly share code, notes, and snippets.

@clonn
Last active August 29, 2015 14:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save clonn/11283289 to your computer and use it in GitHub Desktop.
Save clonn/11283289 to your computer and use it in GitHub Desktop.
app = angular.module("myApp", ["service.create"])
angular.module("myApp").controller("testCtrl", function($scope, create) {
return console.log(create);
});
angular.module("service.create", []).factory('create', function() {
var self;
self = {
"status": "hello"
};
return self;
});
@tomchentw
Copy link

app = angular.module("myApp", ["service.create"])
defines a module here, the "myApp" module dependencies is defined here and cannot be changed. It's dependencies is ["service.create"].

Later, you call angular.module("myApp") to just get the "instance" of that module. It's the same one with previous 'app'. You cannot add dependencies here since it'll create another new module and override "myApp"

@tomchentw
Copy link

I will use
angular.module("myApp", ["myApp.controllers", "myApp.services"]);

angular.module("myApp.controllers", ["ui.router"]);

angular.module("myApp.services", ["ui.bootstrap"]);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment