Created
November 15, 2016 15:55
-
-
Save spiralx/ce37a3c32a94b8402a4af43d5d763798 to your computer and use it in GitHub Desktop.
Gets the injector for the application's root module
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* jshint asi: true, esnext: true */ | |
(() => { | |
'use strict' | |
const ROOT_MODULE = 'app' | |
const rootElement = angular.element(document) | |
const mockApp = angular.module('mockApp', []).provider({ | |
$rootElement: function() { | |
this.$get = function() { | |
return rootElement | |
} | |
} | |
}) | |
function getInjector (...modules) { | |
return angular.injector([ 'ng', 'mockApp', ...modules ]) | |
} | |
const rootInjector = getInjector(ROOT_MODULE) | |
console.dir(rootInjector) | |
Object.assign(window, { | |
rootInjector, | |
getInjector | |
}) | |
})() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment