# Dependency Injection
# article
- services-and-dependency-injection-in-angularjs
- Understanding Dependency Injection - Wiki AngularJS officiel
- source de l'article précédent sur stackoverflow
- AngularJS Dependency Injection - Demystified 20140908
- Injection réfléchie de dépendances - www.developpez.net - 20140804 - SylvainPV
# 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
1
2
3
4
5
6
7
8
9
10
11
12
2
3
4
5
6
7
8
9
10
11
12
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.