AngularTS
    Preparing search index...

    Class Angular

    Main AngularTS runtime entry point with the full built-in ng module configured by default.

    Hierarchy

    • AngularRuntime
      • Angular
    Index

    Constructors

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

      Parameters

      • options: AngularRuntimeConstructorInput = false

      Returns Angular

    Properties

    $eventBus: PubSub

    Application-wide event bus, available after bootstrap providers are created.

    $injector: InjectorService

    Application injector, available after bootstrap() or injector() completes.

    $rootScope: Scope

    Root scope for the bootstrapped application.

    $t: {
        $anchorScroll: "$anchorScroll";
        $anchorScrollProvider: "$anchorScrollProvider";
        $angular: "$angular";
        $angularProvider: "$angularProvider";
        $animate: "$animate";
        $animateProvider: "$animateProvider";
        $aria: "$aria";
        $ariaProvider: "$ariaProvider";
        $compile: "$compile";
        $compileLifecycle: "$compileLifecycle";
        $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";
        $machine: "$machine";
        $machineProvider: "$machineProvider";
        $parse: "$parse";
        $parseProvider: "$parseProvider";
        $provide: "$provide";
        $rest: "$rest";
        $restProvider: "$restProvider";
        $rootElement: "$rootElement";
        $rootScope: "$rootScope";
        $rootScopeProvider: "$rootScopeProvider";
        $sce: "$sce";
        $sceDelegate: "$sceDelegate";
        $sceDelegateProvider: "$sceDelegateProvider";
        $sceProvider: "$sceProvider";
        $scope: "$scope";
        $sse: "$sse";
        $sseProvider: "$sseProvider";
        $state: "$state";
        $stateProvider: "$stateProvider";
        $stateRegistry: "$stateRegistry";
        $stateRegistryProvider: "$stateRegistryProvider";
        $stream: "$stream";
        $streamProvider: "$streamProvider";
        $templateCache: "$templateCache";
        $templateCacheProvider: "$templateCacheProvider";
        $templateFactory: "$templateFactory";
        $templateFactoryProvider: "$templateFactoryProvider";
        $templateRequest: "$templateRequest";
        $templateRequestProvider: "$templateRequestProvider";
        $transitions: "$transitions";
        $transitionsProvider: "$transitionsProvider";
        $view: "$view";
        $viewProvider: "$viewProvider";
        $wasm: "$wasm";
        $wasmProvider: "$wasmProvider";
        $webComponent: "$webComponent";
        $webComponentProvider: "$webComponentProvider";
        $websocket: "$websocket";
        $websocketProvider: "$websocketProvider";
        $webTransport: "$webTransport";
        $webTransportProvider: "$webTransportProvider";
        $window: "$window";
        $worker: "$worker";
        $workerProvider: "$workerProvider";
    } = ...

    Public injection token names keyed by token value.

    errorHandlingConfig: (config?: ErrorHandlingConfig) => ErrorHandlingConfig = errorHandlingConfig

    Global framework error-handling configuration.

    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

    Retrieve the controller instance cached on a compiled DOM element.

    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

    Retrieve the injector cached on a bootstrapped DOM element.

    Type Declaration

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

        Parameters

        • element: Element

        Returns InjectorService

    getNormalizedAttr: (
        element: Node | Element | null | undefined,
        normalizedName: string,
    ) => string | undefined = getNormalizedAttr

    Read an element attribute by normalized directive-style name.

    Type Declaration

      • (
            element: Node | Element | null | undefined,
            normalizedName: string,
        ): string | undefined
      • 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.

        Parameters

        • element: Node | Element | null | undefined
        • normalizedName: string

        Returns string | undefined

    getNormalizedAttrName: (
        element: Node | Element | null | undefined,
        normalizedName: string,
    ) => string | undefined = getNormalizedAttrName

    Return the actual DOM attribute name for a normalized directive-style name.

    Type Declaration

      • (
            element: Node | Element | null | undefined,
            normalizedName: string,
        ): string | undefined
      • Returns the actual DOM attribute name for a normalized directive-style name.

        Parameters

        • element: Node | Element | null | undefined
        • normalizedName: string

        Returns string | undefined

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

    Retrieve the scope cached on a compiled DOM element.

    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.

    hasNormalizedAttr: (
        element: Node | Element | null | undefined,
        normalizedName: string,
    ) => boolean = hasNormalizedAttr

    Return whether an element has an attribute matching a normalized name.

    Type Declaration

      • (element: Node | Element | null | undefined, normalizedName: string): boolean
      • Returns whether an element has an attribute matching a normalized name.

        Parameters

        • element: Node | Element | null | undefined
        • normalizedName: string

        Returns boolean

    subapps: AngularRuntime[] = []

    Sub-application instances created when multiple ng-app roots are initialized.

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

    AngularTS version string replaced at build time.

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

      Parameters

      • element: string | HTMLElement | HTMLDocument

        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.

      • config: AngularBootstrapConfig = ...

      Returns InjectorService

      The created injector instance for this application.

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

      Parameters

      • input: string

      Returns Promise<unknown>

    • 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

    • Find a scope by its registered $scopename.

      Parameters

      • name: string

        Scope name to search for.

      Returns Scope | undefined

      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.

      Parameters

      • element: HTMLElement | HTMLDocument

        Root element or document to scan.

      Returns void

    • Create a standalone injector without bootstrapping the DOM.

      Parameters

      • modules: ModuleLike[]

        Module names or config functions to load.

      • OptionalstrictDi: boolean

        Require explicit dependency annotations.

      Returns InjectorService

      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

      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 use the ng-app directive or bootstrap() to simplify this process.

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

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

      Returns NgModule

      A newly registered module.

    • Registers the configured built-in ng module for this runtime instance.

      Returns NgModule

    • 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