Creates the Angular runtime singleton or a sub-application instance.
Application-wide event bus, available after bootstrap providers are created.
Application injector, available after
bootstrap() or injector() completes.
Root scope for the bootstrapped application.
Public injection token names keyed by token value.
Global framework error-handling configuration.
Gets or updates the global error-handling configuration.
Omitted or undefined options leave the corresponding configuration values unchanged.
Optionalconfig:
ErrorHandlingConfig
Retrieve the controller instance cached on a compiled DOM element.
Gets the controller instance for a given element.
Defaults to
"ngControllerController" when
no controller name is provided.
The DOM element to get data from.
Optionalname:
string
Controller name.
The nearest inherited controller instance if found.
Retrieve the injector cached on a bootstrapped DOM element.
Returns the nearest injector service found while walking up the element tree.
Read an element attribute by normalized directive-style name.
Reads an element attribute by normalized directive-style name.
This mirrors compile-time attribute normalization,
but reads the live element so callers see attribute
aliases such as data-* and later DOM
updates.
Return the actual DOM attribute name for a normalized directive-style name.
Returns the actual DOM attribute name for a normalized directive-style name.
Retrieve the scope cached on a compiled DOM element.
Return whether an element has an attribute matching a normalized name.
Returns whether an element has an attribute matching a normalized name.
Sub-application instances created when multiple
ng-app roots are initialized.
AngularTS version string replaced at build time.
The
addEventListener() method
of the EventTarget interface sets up a function that
will be called whenever the specified event is delivered
to the target.
Optionaloptions:
boolean
|
AddEventListenerOptions
Use this function to manually start up AngularTS application.
AngularTS 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 AngularTS try to work on the DOM.
Note: Do not bootstrap the app on an
element with a directive that uses transclusion, such as
ng-if, ng-include, or
ng-view. Doing this misplaces the app root
element and 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>
let app = angular.module('demo', [])
.controller('WelcomeController', function($scope) {
$scope.greeting = 'Welcome!';
});
angular.bootstrap(document, ['demo']);
</script>
</body>
</html>
DOM element which is the root of AngularTS application.
Optionalmodules:
ModuleLike[]
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
angular.module().
config controls bootstrap behavior
such as strictDi.
The created injector instance for this application.
Await result. Accepts a single string:
"<target>.<expression>"
Dispatches an invocation event to either an injectable service or a named scope.
The event type identifies the target and
the payload contains the expression to evaluate against
that target.
Fire-and-forget. Accepts a single string:
"<target>.<expression>"
Find a scope by its registered $scopename.
Scope name to search for.
The matching scope proxy, or undefined.
Find ng-app roots under the provided
element and bootstrap them.
The first root uses this instance. Additional roots are bootstrapped as sub-applications and stored in subapps.
Root element or document to scan.
Create a standalone injector without bootstrapping the DOM.
Module names or config functions to load.
OptionalstrictDi:
boolean
Require explicit dependency annotations.
The created injector.
The angular.module is a global place for
creating, registering and retrieving AngularTS modules.
All modules (AngularTS core or 3rd party) that should be
available to an application must be registered using
this mechanism.
Passing one argument retrieves an existing ng.NgModule, whereas passing more than one argument creates a new ng.NgModule
A module is a collection of services, directives,
controllers, filters, workers, WebAssembly modules, and
configuration information.
angular.module is used to configure the
auto.$injector $injector.
// Create a new module
let myModule = angular.module('myModule', []);
// register a new service
myModule.value('appName', 'MyCoolApp');
// configure existing services inside initialization blocks.
myModule.config(['$locationProvider', function($locationProvider) {
// Configure existing providers
$locationProvider.hashPrefix('!');
}]);
Then you can create an injector and load your modules like this:
let injector = angular.injector(['ng', 'myModule'])
However it's more likely that you'll use the
ng-app directive or
bootstrap() to simplify this process.
The name of the module to create or retrieve.
Optionalrequires:
string[]
If specified then new module is being created. If unspecified then the module is being retrieved for further configuration.
OptionalconfigFn:
ModuleConfigFn
Optional configuration function for the module
that gets passed to
NgModule.config().
A newly registered module.
Registers the configured built-in ng module
for this runtime instance.
The
removeEventListener()
method of the EventTarget interface removes an event
listener previously registered with
EventTarget.addEventListener() from the target.
Optionaloptions:
boolean
|
EventListenerOptions
Main AngularTS runtime entry point with the full built-in
ngmodule configured by default.