ServiceLocator designed to resolve dependencies in your code if necessary. You donβt want to use a container reference there, as that would be completely against the goal of having code linked.
Personally, I agree with those who say that the service locator itself is an anti-pattern, and should be avoided whenever possible by injecting everything that is possible.
source share