MCPcopy
hub / github.com/angular-ui/ui-router / bootstrap

Function bootstrap

test/angular/1.6/angular.js:1934–2000  ·  view source on GitHub ↗

* @ngdoc function * @name angular.bootstrap * @module ng * @description * Use this function to manually start up AngularJS application. * * For more information, see the guide/bootstrap Bootstrap guide. * * AngularJS will detect if it has been loaded into the browser more than once a

(element, modules, config)

Source from the content-addressed store, hash-verified

1932 * @returns {auto.$injector} Returns the newly created injector for this app.
1933 */
1934function bootstrap(element, modules, config) {
1935 if (!isObject(config)) config = {};
1936 var defaultConfig = {
1937 strictDi: false
1938 };
1939 config = extend(defaultConfig, config);
1940 var doBootstrap = function() {
1941 element = jqLite(element);
1942
1943 if (element.injector()) {
1944 var tag = (element[0] === window.document) ? 'document' : startingTag(element);
1945 // Encode angle brackets to prevent input from being sanitized to empty string #8683.
1946 throw ngMinErr(
1947 'btstrpd',
1948 'App already bootstrapped with this element \'{0}\'',
1949 tag.replace(/</,'&lt;').replace(/>/,'&gt;'));
1950 }
1951
1952 modules = modules || [];
1953 modules.unshift(['$provide', function($provide) {
1954 $provide.value('$rootElement', element);
1955 }]);
1956
1957 if (config.debugInfoEnabled) {
1958 // Pushing so that this overrides `debugInfoEnabled` setting defined in user's `modules`.
1959 modules.push(['$compileProvider', function($compileProvider) {
1960 $compileProvider.debugInfoEnabled(true);
1961 }]);
1962 }
1963
1964 modules.unshift('ng');
1965 var injector = createInjector(modules, config.strictDi);
1966 injector.invoke(['$rootScope', '$rootElement', '$compile', '$injector',
1967 function bootstrapApply(scope, element, compile, injector) {
1968 scope.$apply(function() {
1969 element.data('$injector', injector);
1970 compile(element)(scope);
1971 });
1972 }]
1973 );
1974 return injector;
1975 };
1976
1977 var NG_ENABLE_DEBUG_INFO = /^NG_ENABLE_DEBUG_INFO!/;
1978 var NG_DEFER_BOOTSTRAP = /^NG_DEFER_BOOTSTRAP!/;
1979
1980 if (window && NG_ENABLE_DEBUG_INFO.test(window.name)) {
1981 config.debugInfoEnabled = true;
1982 window.name = window.name.replace(NG_ENABLE_DEBUG_INFO, '');
1983 }
1984
1985 if (window && !NG_DEFER_BOOTSTRAP.test(window.name)) {
1986 return doBootstrap();
1987 }
1988
1989 window.name = window.name.replace(NG_DEFER_BOOTSTRAP, '');
1990 angular.resumeBootstrap = function(extraModules) {
1991 forEach(extraModules, function(module) {

Callers 1

angularInitFunction · 0.70

Calls 5

isObjectFunction · 0.70
extendFunction · 0.70
doBootstrapFunction · 0.70
forEachFunction · 0.70
isFunctionFunction · 0.70

Tested by

no test coverage detected