Skip to content

Instantly share code, notes, and snippets.

@spiralx
Created November 15, 2016 15:55
Show Gist options
  • Save spiralx/ce37a3c32a94b8402a4af43d5d763798 to your computer and use it in GitHub Desktop.
Save spiralx/ce37a3c32a94b8402a4af43d5d763798 to your computer and use it in GitHub Desktop.
Gets the injector for the application's root module
/* 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