Skip to content

Instantly share code, notes, and snippets.

@ericzou
Created December 29, 2012 17:51
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ericzou/4408318 to your computer and use it in GitHub Desktop.
Save ericzou/4408318 to your computer and use it in GitHub Desktop.
Manually bootstrap Angular JS
window.onload = function() {
var $rootElement = angular.element(window.document);
var modules = ['ng', 'myApp', function($provide) {
$provide.value('$rootElement', $rootElement);
}];
var $injector = angular.injector(modules);
var $compile = $injector.get('$compile');
var compositeLinkFn = $compile($rootElement);
var $rootScope = $injector.get('$rootScope');
compositeLinkFn($rootScope);
$rootScope.$apply();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment