Improve this Doc View Source angular.bootstrap

From Get docs
< Function components in ngAngularjs/docs/1.8/api/ng/function/angular.bootstrap

Improve this Doc View Source angular.bootstrap

  1. function in module ng


Use this function to manually start up AngularJS application.

For more information, see the Bootstrap guide.

AngularJS will detect if it has been loaded into the browser more than once and only allow the first loaded script to be bootstrapped and will report a warning to the browser console for each of the subsequent scripts. This prevents strange results in applications, where otherwise multiple instances of AngularJS try to work on the DOM.

Note: Protractor based end-to-end tests cannot use this function to bootstrap manually. They must use ngApp.

Note: Do not bootstrap the app on an element with a directive that uses transclusion, such as ngIf, ngInclude and ngView. Doing this misplaces the app $rootElement and the app's injector, causing animations to stop working and making the injector inaccessible from outside the app.

<!doctype html>
<div ng-controller="WelcomeController">

<script src="angular.js"></script>
  var app = angular.module('demo', [])
  .controller('WelcomeController', function($scope) {
      $scope.greeting = 'Welcome!';
  angular.bootstrap(document, ['demo']);


angular.bootstrap(element, [modules], [config]);


Param Type Details
element DOMElement DOM element which is the root of AngularJS application.



Function|Array>= an array of modules to load into the application. Each item in the array should be the name of a predefined module or a (DI annotated) function that will be invoked by the injector as a config block. See: modules




an object for defining configuration options for the application. The following keys are supported:

  • strictDi - disable automatic function annotation for the application. This is meant to assist in finding bugs which break minified code. Defaults to false.


auto.$injector Returns the newly created injector for this app.

© 2010–2020 Google, Inc.
Licensed under the Creative Commons Attribution License 3.0.