AngularTS
    Preparing search index...

    Class Angular

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

    Hierarchy (View Summary)

    Index

    Constructors

    Properties

    currentInjector: InjectorService

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

    errorFormattingConfig: (config?: ErrorFormattingConfig) => ErrorFormattingConfig = errorFormattingConfig

    Configure how values embedded in framework error messages are formatted.

    Type Declaration

    eventBus: EventBus

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

    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

    rootScope: Scope

    Root scope for the bootstrapped application.

    ScopeElement: typeof ScopeElement = ScopeElement

    Base class for user-authored AngularTS custom elements.

    subapps: AngularRuntime[] = []

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

    tags: ProgrammaticViewTags = tags

    JSX-free real-DOM tag factories for programmatic component views.

    tokens: {
        $anchorScroll: "$anchorScroll";
        $angular: "$angular";
        $animate: "$animate";
        $aria: "$aria";
        $compile: "$compile";
        $controller: "$controller";
        $cookie: "$cookie";
        $document: "$document";
        $element: "$element";
        $eventBus: "$eventBus";
        $exceptionHandler: "$exceptionHandler";
        $filter: "$filter";
        $htmlCanvas: "$htmlCanvas";
        $http: "$http";
        $httpParamSerializer: "$httpParamSerializer";
        $injector: "$injector";
        $interpolate: "$interpolate";
        $location: "$location";
        $log: "$log";
        $machine: "$machine";
        $native: "$native";
        $parse: "$parse";
        $rest: "$rest";
        $rootElement: "$rootElement";
        $rootScope: "$rootScope";
        $scope: "$scope";
        $security: "$security";
        $serviceWorker: "$serviceWorker";
        $sse: "$sse";
        $state: "$state";
        $stateRegistry: "$stateRegistry";
        $storage: "$storage";
        $stream: "$stream";
        $templateCache: "$templateCache";
        $templateRequest: "$templateRequest";
        $transitions: "$transitions";
        $wasm: "$wasm";
        $webComponent: "$webComponent";
        $websocket: "$websocket";
        $webTransport: "$webTransport";
        $window: "$window";
        $worker: "$worker";
        $workflow: "$workflow";
        $workflowSupervisor: "$workflowSupervisor";
    } = ...

    Public injection token names keyed by token value.

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

    AngularTS version string replaced at build time.

    view: Readonly<
        {
            attrs: (
                values: ProgrammaticViewAttributes,
            ) =>
                | {
                    "[attributeGroup]": ProgrammaticViewAttributes;
                    "[propertyGroup]"?: Readonly<Record<string, unknown>>;
                }
                | {
                    "[attributeGroup]"?: Readonly<
                        Record<
                            string,
                            ProgrammaticViewPropertyValue<ProgrammaticViewAttributeValue>,
                        >,
                    >;
                    "[propertyGroup]": ProgrammaticViewLiteralProperties;
                };
            each: <T>(
                read: () => Iterable<T, any, any> | null | undefined,
                key: (item: T) => PropertyKey,
                render: (item: ProgrammaticViewReader<T>) => ProgrammaticViewChild,
            ) => ProgrammaticKeyedView;
            event: <TEvent extends Event = Event>(
                listener:
                    | { handleEvent(event: TEvent): unknown }
                    | ((event: TEvent) => unknown),
                options?: boolean | AddEventListenerOptions,
            ) => EventListener;
            props: (
                values: ProgrammaticViewLiteralProperties,
            ) =>
                | {
                    "[attributeGroup]": ProgrammaticViewAttributes;
                    "[propertyGroup]"?: Readonly<Record<string, unknown>>;
                }
                | {
                    "[attributeGroup]"?: Readonly<
                        Record<
                            string,
                            ProgrammaticViewPropertyValue<ProgrammaticViewAttributeValue>,
                        >,
                    >;
                    "[propertyGroup]": ProgrammaticViewLiteralProperties;
                };
            tag: {
                <Name extends keyof HTMLElementTagNameMap>(
                    name: Name,
                    ...args: readonly (
                        | | {
                            "[attributeGroup]": ProgrammaticViewAttributes;
                            "[propertyGroup]"?: Readonly<Record<string, unknown>>;
                        }
                        | {
                            "[attributeGroup]"?: Readonly<
                                Record<string, ProgrammaticViewPropertyValue<(...)>>,
                            >;
                            "[propertyGroup]": ProgrammaticViewLiteralProperties;
                        }
                        | ProgrammaticViewChild
                        | ProgrammaticViewProperties<Element>
                    )[],
                ): HTMLElementTagNameMap[Name];
                (
                    name: string,
                    ...args: readonly (
                        | | {
                            "[attributeGroup]": ProgrammaticViewAttributes;
                            "[propertyGroup]"?: Readonly<Record<string, unknown>>;
                        }
                        | {
                            "[attributeGroup]"?: Readonly<
                                Record<string, ProgrammaticViewPropertyValue<(...)>>,
                            >;
                            "[propertyGroup]": ProgrammaticViewLiteralProperties;
                        }
                        | ProgrammaticViewChild
                        | ProgrammaticViewProperties<Element>
                    )[],
                ): HTMLElement;
            };
            tagNS: {
                <Name extends keyof SVGElementTagNameMap>(
                    namespaceUri: "http://www.w3.org/2000/svg",
                    name: Name,
                    ...args: readonly (
                        | | {
                            "[attributeGroup]": ProgrammaticViewAttributes;
                            "[propertyGroup]"?: Readonly<Record<string, unknown>>;
                        }
                        | {
                            "[attributeGroup]"?: Readonly<
                                Record<string, ProgrammaticViewPropertyValue<(...)>>,
                            >;
                            "[propertyGroup]": ProgrammaticViewLiteralProperties;
                        }
                        | ProgrammaticViewChild
                        | ProgrammaticViewProperties<Element>
                    )[],
                ): SVGElementTagNameMap[Name];
                <Name extends keyof MathMLElementTagNameMap>(
                    namespaceUri: "http://www.w3.org/1998/Math/MathML",
                    name: Name,
                    ...args: readonly (
                        | | {
                            "[attributeGroup]": ProgrammaticViewAttributes;
                            "[propertyGroup]"?: Readonly<Record<string, unknown>>;
                        }
                        | {
                            "[attributeGroup]"?: Readonly<
                                Record<string, ProgrammaticViewPropertyValue<(...)>>,
                            >;
                            "[propertyGroup]": ProgrammaticViewLiteralProperties;
                        }
                        | ProgrammaticViewChild
                        | ProgrammaticViewProperties<Element>
                    )[],
                ): MathMLElementTagNameMap[Name];
            };
            tags: ProgrammaticViewTags;
        },
    > = ...

    Explicit programmatic-view binding and element helpers.

    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.createModule('demo', [])
      .controller('WelcomeController', ['$scope', 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.createModule() and angular.getModule().

      Returns InjectorService

      The created injector instance for this application.

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

      Parameters

      • input: string

      Returns Promise<unknown>

    • Creates or replaces an AngularTS module.

      A module collects services, directives, controllers, filters, workers, WebAssembly modules, and configuration for an application.

      Parameters

      • name: string

        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().

      Returns NgModule

      A newly registered module.

      const app = angular.createModule("myApp", ["ng"]);
      app.value("appName", "My app");
    • Creates or replaces an AngularTS module.

      A module collects services, directives, controllers, filters, workers, WebAssembly modules, and configuration for an application.

      Type Parameters

      Parameters

      • name: string

        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().

      Returns RouterModule<TRouteMap>

      A newly registered module.

      const app = angular.createModule("myApp", ["ng"]);
      app.value("appName", "My app");
    • 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

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

      Type Parameters

      • T extends { [key: string]: unknown } = { [key: string]: unknown }

      Parameters

      • name: string

        Name registered with NgModule.model().

      Returns Model<T>

      The shared reactive model instance.

      const cart = angular.getModel<{ items: string[] }>("cart");
      cart.items.push("book");

      If the runtime is uninitialized or destroyed, the name is not a loaded model, or its injectable registration no longer resolves to a model.

    • Find a scope by its registered scopeName.

      Parameters

      • name: string

        Scope name to search for.

      Returns Scope | undefined

      The matching scope proxy, or undefined.

    • Create a standalone injector without bootstrapping the DOM.

      Parameters

      • modules: ModuleLike[]

        Module names or config functions to load.

      Returns InjectorService

      The created injector.

    • 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