Skip to content Skip to sidebar Skip to footer

AngularJS Name Collision In Dependency Injection?

Say I have two modules (finance2, finance3), and each of them defines a service with the same name (currencyConverter). If I tell my main module that it depends on just finance2, I

Solution 1:

The last one loaded/processed will win.

If your scripts are:

  • finance2 (with currencyConverter)
  • finance3 (with currencyConverter)

Then you will get finance3's currencyConverter when the dependency for currencyConverter is resolved.

If your scripts are:

  • finance3 (with currencyConverter)
  • finance2 (with currencyConverter)

Then you will get finance2's currencyConverter when the dependency for currencyConverter is resolved.


Post a Comment for "AngularJS Name Collision In Dependency Injection?"