Note that it is angular1.5.x, not 2
I rely on the ngResource module and a custom foo module in the root module (App). To use the services of the ngResource module, my foo module does not need to be introduced again. When did angular Introduce the ngResource module into the foo module?
Although we all know that this app module is a root module, I did not tell angular anywhere that this app is my root module?
app.js
angular.module('app', ['foo','ngResource']);
foo.js
var phone = angular.module('foo', []);
phone.factory('Foo', ['$resource'], function($resource) {
// 使用$resource
})
With this code, how can the Foo module automatically inject $resource?
phpcn_u15822017-05-15 17:15:45
Regarding dependency injection, it is maintained by Angular. Naturally, everything that has been injected will not be loaded repeatedly.
And app is the root module, it depends on how you enable your Angular, such as:
ng-app="app"
or
angular.bootstrap(document, ['app']);
are all explicitly stated app
as the start of enabling the module.