diff options
| author | Misko Hevery | 2011-11-10 20:04:15 -0800 |
|---|---|---|
| committer | Misko Hevery | 2011-11-14 20:31:18 -0800 |
| commit | 186a840cd34d3ffed7b351a1827e7736cd8d54c3 (patch) | |
| tree | 3f67580bd1526535439d19308abbe62e31666209 /src | |
| parent | b09595a3c12ba761772084b94767b635c5bbfaf2 (diff) | |
| download | angular.js-186a840cd34d3ffed7b351a1827e7736cd8d54c3.tar.bz2 | |
feat(bootstrap): added angular.bootstrap method
Diffstat (limited to 'src')
| -rw-r--r-- | src/Angular.js | 34 |
1 files changed, 25 insertions, 9 deletions
diff --git a/src/Angular.js b/src/Angular.js index 66b592f2..096f5b53 100644 --- a/src/Angular.js +++ b/src/Angular.js @@ -819,29 +819,44 @@ function encodeUriQuery(val, pctEncodeSpaces) { * `ng:autobind="[root element ID]"` tells Angular to compile and manage part of the document, * starting at "root element ID". * - */ function angularInit(config, document){ var autobind = config.autobind; if (autobind) { - var modules = [ngModule]; + var modules = []; forEach((config.modules || '').split(','), function(module){ module = trim(module); if (module) { modules.push(module); } }); - createInjector(modules, angularModule)(['$rootScope', '$compile', '$injector', function(scope, compile, injector){ - scope.$apply(function(){ - var element = jqLite(isString(autobind) ? document.getElementById(autobind) : document); - element.data('$injector', injector); - compile(element)(scope); - }); - }]); + bootstrap(jqLite(isString(autobind) ? document.getElementById(autobind) : document), modules); } } +/** + * @ngdoc function + * @name angular.bootstrap + * @description + * Use this function to manually start up angular application. + * + * See: {@link guide/dev_guide.bootstrap.manual_bootstrap Bootstrap} + * + * @param {Element} element DOM element which is the root of angular application. + * @param {Array<String,function>=} modules an array of module declarations. See: {@link angular.module modules} + */ +function bootstrap(element, modules) { + modules = modules || []; + modules.unshift(ngModule); + createInjector(modules, angularModule)(['$rootScope', '$compile', '$injector', function(scope, compile, injector){ + scope.$apply(function() { + element.data('$injector', injector); + compile(element)(scope); + }); + }]); +} + function angularJsConfig(document) { bindJQuery(); var scripts = document.getElementsByTagName('script'), @@ -903,6 +918,7 @@ function assertArgFn(arg, name) { function publishExternalAPI(angular){ extend(angular, { + 'bootstrap': bootstrap, 'copy': copy, 'extend': extend, 'equals': equals, |
