AngularJS Dynamic Injections


There is also an option to dynamically request components. You can do it using the $injector service:

myModule.controller('myController', ['$injector', function($injector) {
    var myService = $injector.get('myService');

Note: while this method could be used to prevent the circular dependency issue that might break your app, it is not considered best practice to bypass the problem by using it. Circular dependency usually indicates there is a flaw in your application's architecture, and you should address that instead.