OpenProject is the leading open source project management software.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 
openproject/frontend/app/components/angular/angular-injector-bridge.fun...

22 lines
693 B

/**
* Returns the currently bootstrapped injector from the application.
* Not applicable until after the application bootstrapping is done.
*/
export function $currentInjector() {
return angular.element(document.body).injector();
}
/**
* Detects desired injections from `target.$inject = [...]` definitions
* analogous to how angular does its DI, only that we're not registering the
* factory.
*
* @param injectable The target to inject into
*/
export function injectorBridge(injectable) {
let $injector = $currentInjector();
$injector.annotate(injectable.constructor).forEach(dep => {
injectable[dep] = $injector.get(dep);
});
}