Creates the Angular runtime singleton or a sub-application instance.
when true, skips assigning the instance to window.angular
Gets or updates the global error-handling configuration.
Omitted or undefined options leave the corresponding configuration values unchanged.
Optionalconfig: ErrorHandlingConfigGets the controller instance for a given element.
Defaults to "ngControllerController" when no controller name is provided.
The DOM element to get data from.
Optionalname: stringController name.
The nearest inherited controller instance if found.
Returns the nearest injector service found while walking up the element tree.
Gets the scope attached directly to an element.
The DOM element to get data from.
The scope stored on the element.
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 | AddEventListenerOptionsUse 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.
<!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: any[]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 modules
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>"
Finds a scope by its registered $scopename.
Finds ng-app roots under the provided element and bootstraps them.
Creates a standalone injector without bootstrapping the DOM.
OptionalstrictDi: booleanThe 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 just use
ng-app directive or
bootstrap to simplify this process for you.
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: anyOptional configuration function for the module that gets
passed to NgModule.config().
A newly registered module.
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.