* @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)
| 1660 | * @returns {auto.$injector} Returns the newly created injector for this app. |
| 1661 | */ |
| 1662 | function bootstrap(element, modules, config) { |
| 1663 | if (!isObject(config)) config = {}; |
| 1664 | var defaultConfig = { |
| 1665 | strictDi: false |
| 1666 | }; |
| 1667 | config = extend(defaultConfig, config); |
| 1668 | var doBootstrap = function() { |
| 1669 | element = jqLite(element); |
| 1670 | |
| 1671 | if (element.injector()) { |
| 1672 | var tag = (element[0] === document) ? 'document' : startingTag(element); |
| 1673 | //Encode angle brackets to prevent input from being sanitized to empty string #8683 |
| 1674 | throw ngMinErr( |
| 1675 | 'btstrpd', |
| 1676 | "App already bootstrapped with this element '{0}'", |
| 1677 | tag.replace(/</,'<').replace(/>/,'>')); |
| 1678 | } |
| 1679 | |
| 1680 | modules = modules || []; |
| 1681 | modules.unshift(['$provide', function($provide) { |
| 1682 | $provide.value('$rootElement', element); |
| 1683 | }]); |
| 1684 | |
| 1685 | if (config.debugInfoEnabled) { |
| 1686 | // Pushing so that this overrides `debugInfoEnabled` setting defined in user's `modules`. |
| 1687 | modules.push(['$compileProvider', function($compileProvider) { |
| 1688 | $compileProvider.debugInfoEnabled(true); |
| 1689 | }]); |
| 1690 | } |
| 1691 | |
| 1692 | modules.unshift('ng'); |
| 1693 | var injector = createInjector(modules, config.strictDi); |
| 1694 | injector.invoke(['$rootScope', '$rootElement', '$compile', '$injector', |
| 1695 | function bootstrapApply(scope, element, compile, injector) { |
| 1696 | scope.$apply(function() { |
| 1697 | element.data('$injector', injector); |
| 1698 | compile(element)(scope); |
| 1699 | }); |
| 1700 | }] |
| 1701 | ); |
| 1702 | return injector; |
| 1703 | }; |
| 1704 | |
| 1705 | var NG_ENABLE_DEBUG_INFO = /^NG_ENABLE_DEBUG_INFO!/; |
| 1706 | var NG_DEFER_BOOTSTRAP = /^NG_DEFER_BOOTSTRAP!/; |
| 1707 | |
| 1708 | if (window && NG_ENABLE_DEBUG_INFO.test(window.name)) { |
| 1709 | config.debugInfoEnabled = true; |
| 1710 | window.name = window.name.replace(NG_ENABLE_DEBUG_INFO, ''); |
| 1711 | } |
| 1712 | |
| 1713 | if (window && !NG_DEFER_BOOTSTRAP.test(window.name)) { |
| 1714 | return doBootstrap(); |
| 1715 | } |
| 1716 | |
| 1717 | window.name = window.name.replace(NG_DEFER_BOOTSTRAP, ''); |
| 1718 | angular.resumeBootstrap = function(extraModules) { |
| 1719 | forEach(extraModules, function(module) { |
no test coverage detected