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