* @ngdoc function * @name angular.bootstrap * @module ng * @description * Use this function to manually start up angular application. * * See: guide/bootstrap Bootstrap * * Note that ngScenario-based end-to-end tests cannot use this function to bootstrap manually. * They must use {@
(element, modules)
| 1426 | * @returns {auto.$injector} Returns the newly created injector for this app. |
| 1427 | */ |
| 1428 | function bootstrap(element, modules) { |
| 1429 | var doBootstrap = function() { |
| 1430 | element = jqLite(element); |
| 1431 | |
| 1432 | if (element.injector()) { |
| 1433 | var tag = (element[0] === document) ? 'document' : startingTag(element); |
| 1434 | //Encode angle brackets to prevent input from being sanitized to empty string #8683 |
| 1435 | throw ngMinErr( |
| 1436 | 'btstrpd', |
| 1437 | "App Already Bootstrapped with this Element '{0}'", |
| 1438 | tag.replace(/</,'<').replace(/>/,'>')); |
| 1439 | } |
| 1440 | |
| 1441 | modules = modules || []; |
| 1442 | modules.unshift(['$provide', function($provide) { |
| 1443 | $provide.value('$rootElement', element); |
| 1444 | }]); |
| 1445 | modules.unshift('ng'); |
| 1446 | var injector = createInjector(modules); |
| 1447 | injector.invoke(['$rootScope', '$rootElement', '$compile', '$injector', '$animate', |
| 1448 | function(scope, element, compile, injector, animate) { |
| 1449 | scope.$apply(function() { |
| 1450 | element.data('$injector', injector); |
| 1451 | compile(element)(scope); |
| 1452 | }); |
| 1453 | }] |
| 1454 | ); |
| 1455 | return injector; |
| 1456 | }; |
| 1457 | |
| 1458 | var NG_DEFER_BOOTSTRAP = /^NG_DEFER_BOOTSTRAP!/; |
| 1459 | |
| 1460 | if (window && !NG_DEFER_BOOTSTRAP.test(window.name)) { |
| 1461 | return doBootstrap(); |
| 1462 | } |
| 1463 | |
| 1464 | window.name = window.name.replace(NG_DEFER_BOOTSTRAP, ''); |
| 1465 | angular.resumeBootstrap = function(extraModules) { |
| 1466 | forEach(extraModules, function(module) { |
| 1467 | modules.push(module); |
| 1468 | }); |
| 1469 | doBootstrap(); |
| 1470 | }; |
| 1471 | } |
| 1472 | |
| 1473 | var SNAKE_CASE_REGEXP = /[A-Z]/g; |
| 1474 | function snake_case(name, separator) { |
no test coverage detected