Created
January 15, 2017 15:22
-
-
Save msacket/79cc0160513aa1fe834c3201a6519571 to your computer and use it in GitHub Desktop.
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
/** | |
* xg-bootstrap.js | |
* | |
* Injects an Angular module into the DOM asynchronously and returns a promise | |
* to resolve when the injection is complete. | |
*/ | |
define(['angular'], function(angular) { | |
return function(app, appEl, $selector){ | |
var d; | |
angular.injector(['ng']).invoke(['$q', function($q){ | |
d = $q.defer(); | |
angular.element($selector || 'body').append(appEl); | |
angular.bootstrap(appEl, [app.name]); | |
d.resolve({ | |
'app': app, | |
'appEl': appEl, | |
'scope': appEl.scope() | |
}); | |
}]); | |
return d.promise; | |
}; | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment