Are dependencies related?

Say I have 3 modules:

angular.module('A', [])

angular.module('B', ['A'])

angular.module('C', ['B', 'A'])

In terms of dependency injection, will Bthey Cshare the same instance of the module Aor will separate instances be injected into each of them?

+4
source share
1 answer

To summarize your question, the answer will be just one copy.

Actually it is. Angular application resolves dependencies through injector. Only one injector is created for each application. Technically, you can have only one ng-app, but you can have several applications using manual loading, in this case an injector will be created for each application, and these 2 applications will not share any dependencies.

, rootElement Angular. , , ( ). // .., , - ( ) . , , myService, A. , A , , , , .

:

. , . , . . , .

+4

All Articles