Skip to content

Instantly share code, notes, and snippets.

@msacket
Created January 15, 2017 15:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save msacket/79cc0160513aa1fe834c3201a6519571 to your computer and use it in GitHub Desktop.
Save msacket/79cc0160513aa1fe834c3201a6519571 to your computer and use it in GitHub Desktop.
/**
* 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