javascript - AngularJs - dependency injection

Dependency Injection

article

scope and namespace with the angular injector

For services, angularJs injector is flat.

For constants, angularJs injector is namespaced.

Exemple, for a module structure like this :

app

app.moduleA
app.moduleA.aaaaService
app.moduleA.aaaaConstants
app.moduleA.subModuleA
app.moduleA.subaaaaModuleA

app.moduleB.bbbbService
app.moduleB.bbbbConstants
app.moduleB.subModuleB
app.moduleB.subbbbbModuleB

If you call bbbbService in aaaaService without linking the depency in moduleA module declaration, it will works. AngularJs injector is flat in that case.

If you call bbbbConstants in aaaaService without linking the dependency in moduleA module declaration, it will fail. AngularJs injector is not flat in that case.

results for ""

    No results matching ""