* @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)
| 1597 | * @returns {auto.$injector} Returns the newly created injector for this app. |
| 1598 | */ |
| 1599 | function bootstrap(element, modules, config) { |
| 1600 | if (!isObject(config)) config = {}; |
| 1601 | var defaultConfig = { |
| 1602 | strictDi: false |
| 1603 | }; |
| 1604 | config = extend(defaultConfig, config); |
| 1605 | var doBootstrap = function() { |
| 1606 | element = jqLite(element); |
| 1607 | |
| 1608 | if (element.injector()) { |
| 1609 | var tag = (element[0] === document) ? 'document' : startingTag(element); |
| 1610 | //Encode angle brackets to prevent input from being sanitized to empty string #8683 |
| 1611 | throw ngMinErr( |
| 1612 | 'btstrpd', |
| 1613 | "App Already Bootstrapped with this Element '{0}'", |
| 1614 | tag.replace(/</,'<').replace(/>/,'>')); |
| 1615 | } |
| 1616 | |
| 1617 | modules = modules || []; |
| 1618 | modules.unshift(['$provide', function($provide) { |
| 1619 | $provide.value('$rootElement', element); |
| 1620 | }]); |
| 1621 | |
| 1622 | if (config.debugInfoEnabled) { |
| 1623 | // Pushing so that this overrides `debugInfoEnabled` setting defined in user's `modules`. |
| 1624 | modules.push(['$compileProvider', function($compileProvider) { |
| 1625 | $compileProvider.debugInfoEnabled(true); |
| 1626 | }]); |
| 1627 | } |
| 1628 | |
| 1629 | modules.unshift('ng'); |
| 1630 | var injector = createInjector(modules, config.strictDi); |
| 1631 | injector.invoke(['$rootScope', '$rootElement', '$compile', '$injector', |
| 1632 | function bootstrapApply(scope, element, compile, injector) { |
| 1633 | scope.$apply(function() { |
| 1634 | element.data('$injector', injector); |
| 1635 | compile(element)(scope); |
| 1636 | }); |
| 1637 | }] |
| 1638 | ); |
| 1639 | return injector; |
| 1640 | }; |
| 1641 | |
| 1642 | var NG_ENABLE_DEBUG_INFO = /^NG_ENABLE_DEBUG_INFO!/; |
| 1643 | var NG_DEFER_BOOTSTRAP = /^NG_DEFER_BOOTSTRAP!/; |
| 1644 | |
| 1645 | if (window && NG_ENABLE_DEBUG_INFO.test(window.name)) { |
| 1646 | config.debugInfoEnabled = true; |
| 1647 | window.name = window.name.replace(NG_ENABLE_DEBUG_INFO, ''); |
| 1648 | } |
| 1649 | |
| 1650 | if (window && !NG_DEFER_BOOTSTRAP.test(window.name)) { |
| 1651 | return doBootstrap(); |
| 1652 | } |
| 1653 | |
| 1654 | window.name = window.name.replace(NG_DEFER_BOOTSTRAP, ''); |
| 1655 | angular.resumeBootstrap = function(extraModules) { |
| 1656 | forEach(extraModules, function(module) { |
no test coverage detected