AngularTS
    Preparing search index...

    Class Angular

    Main Angular runtime entry point.

    It owns module registration, application bootstrap, injector access, and the lightweight event-based invocation helpers exposed on window.angular.

    Hierarchy

    • EventTarget
      • Angular
    Index

    Constructors

    • Creates the Angular runtime singleton or a sub-application instance.

      Parameters

      • subapp: boolean = false

        when true, skips assigning the instance to window.angular

      Returns Angular

    Properties

    _bootsrappedModules: any[] = []
    _subapp: boolean
    $eventBus: PubSub
    $injector: InjectorService
    $rootScope: Scope
    $t: {
        $anchorScroll: "$anchorScroll";
        $anchorScrollProvider: "$anchorScrollProvider";
        $angular: "$angular";
        $angularProvider: "$angularProvider";
        $animate: "$animate";
        $animateCss: "$animateCss";
        $animateCssProvider: "$animateCssProvider";
        $animateProvider: "$animateProvider";
        $aria: "$aria";
        $ariaProvider: "$ariaProvider";
        $attrs: "$attrs";
        $compile: "$compile";
        $compileProvider: "$compileProvider";
        $controller: "$controller";
        $controllerProvider: "$controllerProvider";
        $cookie: "$cookie";
        $cookieProvider: "$cookieProvider";
        $document: "$document";
        $element: "$element";
        $eventBus: "$eventBus";
        $eventBusProvider: "$eventBusProvider";
        $exceptionHandler: "$exceptionHandler";
        $exceptionHandlerProvider: "$exceptionHandlerProvider";
        $filter: "$filter";
        $filterProvider: "$filterProvider";
        $http: "$http";
        $httpParamSerializer: "$httpParamSerializer";
        $httpParamSerializerProvider: "$httpParamSerializerProvider";
        $httpProvider: "$httpProvider";
        $injector: "$injector";
        $interpolate: "$interpolate";
        $interpolateProvider: "$interpolateProvider";
        $location: "$location";
        $locationProvider: "$locationProvider";
        $log: "$log";
        $logProvider: "$logProvider";
        $parse: "$parse";
        $parseProvider: "$parseProvider";
        $provide: "$provide";
        $rest: "$rest";
        $restProvider: "$restProvider";
        $rootElement: "$rootElement";
        $rootScope: "$rootScope";
        $rootScopeProvider: "$rootScopeProvider";
        $router: "$router";
        $routerProvider: "$routerProvider";
        $sce: "$sce";
        $sceDelegate: "$sceDelegate";
        $sceDelegateProvider: "$sceDelegateProvider";
        $sceProvider: "$sceProvider";
        $scope: "$scope";
        $sse: "$sse";
        $sseProvider: "$sseProvider";
        $state: "$state";
        $stateProvider: "$stateProvider";
        $stateRegistry: "$stateRegistry";
        $stateRegistryProvider: "$stateRegistryProvider";
        $templateCache: "$templateCache";
        $templateCacheProvider: "$templateCacheProvider";
        $templateFactory: "$templateFactory";
        $templateFactoryProvider: "$templateFactoryProvider";
        $templateRequest: "$templateRequest";
        $templateRequestProvider: "$templateRequestProvider";
        $transitions: "$transitions";
        $transitionsProvider: "$transitionsProvider";
        $url: "$url";
        $urlConfig: "$urlConfig";
        $urlConfigProvider: "$urlConfigProvider";
        $urlProvider: "$urlProvider";
        $view: "$view";
        $viewProvider: "$viewProvider";
        $websocket: "$websocket";
        $websocketProvider: "$websocketProvider";
        $window: "$window";
    } = ...
    errorHandlingConfig: (config?: ErrorHandlingConfig) => ErrorHandlingConfig = errorHandlingConfig

    Type Declaration

      • (config?: ErrorHandlingConfig): ErrorHandlingConfig
      • Gets or updates the global error-handling configuration.

        Omitted or undefined options leave the corresponding configuration values unchanged.

        Parameters

        • Optionalconfig: ErrorHandlingConfig

        Returns ErrorHandlingConfig

    getController: (element: Element, name?: string) => Scope | undefined = getController

    Type Declaration

      • (element: Element, name?: string): Scope | undefined
      • Gets the controller instance for a given element.

        Defaults to "ngControllerController" when no controller name is provided.

        Parameters

        • element: Element

          The DOM element to get data from.

        • Optionalname: string

          Controller name.

        Returns Scope | undefined

        The nearest inherited controller instance if found.

    getInjector: (element: Element) => InjectorService = getInjector

    Type Declaration

      • (element: Element): InjectorService
      • Returns the nearest injector service found while walking up the element tree.

        Parameters

        • element: Element

        Returns InjectorService

    getScope: (element: Element) => Scope = getScope

    Type Declaration

      • (element: Element): Scope
      • Gets the scope attached directly to an element.

        Parameters

        • element: Element

          The DOM element to get data from.

        Returns Scope

        The scope stored on the element.

    subapps: Angular[] = []
    version: string = "[VI]{version}[/VI]"

    Methods

    • The addEventListener() method of the EventTarget interface sets up a function that will be called whenever the specified event is delivered to the target.

      MDN Reference

      Parameters

      • type: string
      • callback: EventListenerOrEventListenerObject | null
      • Optionaloptions: boolean | AddEventListenerOptions

      Returns void

    • 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 ng.$compile#transclusion transclusion, such as ng.ngIf `ngIf`, ng.ngInclude `ngInclude` and ngRoute.ngView `ngView`. Doing this misplaces the app ng.$rootElement `$rootElement` and the app's auto.$injector 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>

      Parameters

      • element: string | HTMLElement | HTMLDocument

        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.

      • config: AngularBootstrapConfig = ...

      Returns InjectorService

      The created injector instance for this application.

    • Await result. Accepts a single string: "<target>.<expression>"

      Parameters

      • input: string

      Returns Promise<any>

    • 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.

      Parameters

      • event: Event

      Returns boolean

    • Fire-and-forget. Accepts a single string: "<target>.<expression>"

      Parameters

      • input: string

      Returns void

    • Finds a scope by its registered $scopename.

      Parameters

      • name: string

      Returns Scope | undefined

    • Finds ng-app roots under the provided element and bootstraps them.

      Parameters

      • element: HTMLElement | HTMLDocument

      Returns void

    • Creates a standalone injector without bootstrapping the DOM.

      Parameters

      • modules: any[]
      • OptionalstrictDi: boolean

      Returns InjectorService

    • 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

      Module

      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.

      Parameters

      • name: string

        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: any

        Optional configuration function for the module that gets passed to NgModule.config().

      Returns NgModule

      A newly registered module.

    • The removeEventListener() method of the EventTarget interface removes an event listener previously registered with EventTarget.addEventListener() from the target.

      MDN Reference

      Parameters

      • type: string
      • callback: EventListenerOrEventListenerObject | null
      • Optionaloptions: boolean | EventListenerOptions

      Returns void