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

Function bootstrap

test/angular/1.7/angular.js:1931–1997  ·  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

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