- function in module ng
Use this function to manually start up angular application.
For more information, see the Bootstrap guide.
Angular 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 Angular try to work on the DOM.
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> <html> <body> <div ng-controller="WelcomeController"> {{greeting}} </div> <script src="angular.js"></script> <script> var app = angular.module('demo', []) .controller('WelcomeController', function($scope) { $scope.greeting = 'Welcome!'; }); angular.bootstrap(document, ['demo']); </script> </body> </html>
Usage
angular.bootstrap(element, [modules], [config]);
Arguments
Param | Type | Details |
---|---|---|
element | DOMElement | DOM element which is the root of angular application. |
modules (optional) | Array<String|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 (optional) | Object | an object for defining configuration options for the application. The following keys are supported:
|
Returns
auto.$injector |
Returns the newly created injector for this app. |
Please login to continue.