In this section, we will take a look at how we can build a hierarchy of injectors. There's no alternative to this concept in AngularJS. Each injector can have either zero or one parent injectors, and each parent injector can have one or more children. In contrast to AngularJS, where all the registered providers are stored in a flat structure, in Angular they are stored in a tree. The flat structure is more limited; for instance, it doesn't support the namespacing of tokens; we cannot declare different providers for the same token. So far, we looked at an example of an injector that doesn't have any children or a parent. Now, let's build a hierarchy of injectors.
In order to gain a better understanding of this hierarchical structure of injectors, let's take a look at the following diagram:
Here, we see a tree where...