MCPcopy Create free account
hub / github.com/cafebazaar/blacksmith / bootstrap

Function bootstrap

web/static/bower_components/angular/angular.js:1626–1692  ·  view source on GitHub ↗

* @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)

Source from the content-addressed store, hash-verified

1624 * @returns {auto.$injector} Returns the newly created injector for this app.
1625 */
1626function bootstrap(element, modules, config) {
1627 if (!isObject(config)) config = {};
1628 var defaultConfig = {
1629 strictDi: false
1630 };
1631 config = extend(defaultConfig, config);
1632 var doBootstrap = function() {
1633 element = jqLite(element);
1634
1635 if (element.injector()) {
1636 var tag = (element[0] === document) ? 'document' : startingTag(element);
1637 //Encode angle brackets to prevent input from being sanitized to empty string #8683
1638 throw ngMinErr(
1639 'btstrpd',
1640 "App Already Bootstrapped with this Element '{0}'",
1641 tag.replace(/</,'&lt;').replace(/>/,'&gt;'));
1642 }
1643
1644 modules = modules || [];
1645 modules.unshift(['$provide', function($provide) {
1646 $provide.value('$rootElement', element);
1647 }]);
1648
1649 if (config.debugInfoEnabled) {
1650 // Pushing so that this overrides `debugInfoEnabled` setting defined in user's `modules`.
1651 modules.push(['$compileProvider', function($compileProvider) {
1652 $compileProvider.debugInfoEnabled(true);
1653 }]);
1654 }
1655
1656 modules.unshift('ng');
1657 var injector = createInjector(modules, config.strictDi);
1658 injector.invoke(['$rootScope', '$rootElement', '$compile', '$injector',
1659 function bootstrapApply(scope, element, compile, injector) {
1660 scope.$apply(function() {
1661 element.data('$injector', injector);
1662 compile(element)(scope);
1663 });
1664 }]
1665 );
1666 return injector;
1667 };
1668
1669 var NG_ENABLE_DEBUG_INFO = /^NG_ENABLE_DEBUG_INFO!/;
1670 var NG_DEFER_BOOTSTRAP = /^NG_DEFER_BOOTSTRAP!/;
1671
1672 if (window && NG_ENABLE_DEBUG_INFO.test(window.name)) {
1673 config.debugInfoEnabled = true;
1674 window.name = window.name.replace(NG_ENABLE_DEBUG_INFO, '');
1675 }
1676
1677 if (window && !NG_DEFER_BOOTSTRAP.test(window.name)) {
1678 return doBootstrap();
1679 }
1680
1681 window.name = window.name.replace(NG_DEFER_BOOTSTRAP, '');
1682 angular.resumeBootstrap = function(extraModules) {
1683 forEach(extraModules, function(module) {

Callers 1

angularInitFunction · 0.85

Calls 5

isObjectFunction · 0.85
extendFunction · 0.85
doBootstrapFunction · 0.85
forEachFunction · 0.85
isFunctionFunction · 0.85

Tested by

no test coverage detected