The order of providers in Angular Dependency Injection matters.
If you provide a custom implementation "before" the default implementation is provided, then the default implementation will take precedence. The "last provided" wins. Angular traverses the tree of modules, grabs all providers and flatten them all to one list. In case of conflicts, then the last provided in the list wins.
Angular traverses modules tree, starting from the root module (often named
- first are providers from imported modules (depth-first), e.g.
imports: [SomeModule, ...]
- then providers from static methods of imported modules, e.g.
imports: [SomeModule.forRootOrWhateverMethodName(), ...]
- then providers from the currently analyzed module