Creates the Angular runtime singleton or a sub-application instance.
runtime construction options. Passing
true creates a sub-application and
skips assigning the instance to
window.angular.
Application injector, available after
bootstrap() or injector() completes.
Configure how values embedded in framework error messages are formatted.
Gets or updates global error-message formatting.
Omitted or undefined options leave the corresponding configuration values unchanged.
Optionalconfig:
ErrorFormattingConfig
Application-wide event bus, available after bootstrap providers are created.
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.
Root scope for the bootstrapped application.
Sub-application instances created when multiple
ng-app roots are initialized.
Public injection token names keyed by token value.
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.createModule('demo', [])
.controller('WelcomeController', ['$scope', 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.createModule() and
angular.getModule().
The created injector instance for this application.
Await result. Accepts a single string:
"<target>.<expression>"
Creates or replaces an AngularTS module.
A module collects services, directives, controllers, filters, workers, WebAssembly modules, and configuration for an application.
The name of the module to create.
Optionalrequires:
string[]
The modules required by the new module.
OptionalconfigFn:
ModuleConfigFn
Optional configuration function for the module
that gets passed to
NgModule.config().
A newly registered module.
Creates or replaces an AngularTS module.
A module collects services, directives, controllers, filters, workers, WebAssembly modules, and configuration for an application.
The name of the module to create.
Optionalrequires:
string[]
The modules required by the new module.
OptionalconfigFn:
ModuleConfigFn
Optional configuration function for the module
that gets passed to
NgModule.config().
A newly registered module.
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>"
Retrieve a reactive model declared by a loaded application module.
After bootstrap() or
injector() completes, the first lookup
initializes the model through dependency injection.
Later lookups and injected consumers receive the same
app-owned reactive instance. External callbacks can
mutate this instance directly to update every observing
view.
Name registered with
NgModule.model().
The shared reactive model instance.
Retrieves an existing module.
The name of the module to retrieve.
The registered module.
Retrieves an existing module.
The name of the module to retrieve.
The registered module.
Find a scope by its registered scopeName.
Scope name to search for.
The matching scope proxy, or undefined.
Create a standalone injector without bootstrapping the DOM.
Module names or config functions to load.
The created injector.
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 Angular runtime entry point.
It owns module registration, application bootstrap, injector access, and the lightweight event-based invocation helpers exposed on
window.angular.