AngularTS
    Preparing search index...

    Interface Provider

    The API for registering different types of providers with the injector.

    This interface is used within AngularTS's $provide service to define services, factories, constants, values, decorators, etc.

    interface Provider {
        constant(name: string, val: any): Provider;
        decorator(name: string, fn: Function): Provider;
        directive(name: string, directive: DirectiveFactory): Provider;
        directive(obj: Record<string, DirectiveFactory>): Provider;
        factory(name: string, factoryFn: any): Provider;
        provider(name: string, provider: Function): Provider;
        provider(obj: Record<string, Function>): Provider;
        service(name: string, constructor: any): Provider;
        value(name: string, val: any): Provider;
    }
    Index

    Methods

    • Register a constant service, such as a string, a number, an array, an object or a function, with the $injector. Unlike value it can be injected into a module configuration function (see config) and it cannot be overridden by an Angular decorator.

      Parameters

      • name: string

        The name of the constant.

      • val: any

        The constant value.

      Returns Provider

    • Register a decorator function to modify or replace an existing service.

      Parameters

      • name: string

        The name of the service to decorate.

      • fn: Function

        A function that takes $delegate and returns a decorated service.

      Returns Provider

    • Register a factory function to create a service.

      Parameters

      • name: string

        The name of the service.

      • factoryFn: any

        A function (or annotated array) that returns the service instance.

      Returns Provider

    • Register a service provider.

      Parameters

      • name: string

        The name of the service.

      • provider: Function

        An object with a $get property that defines how the service is created.

      Returns Provider

    • Register multiple service providers

      Parameters

      • obj: Record<string, Function>

      Returns Provider

    • Register a constructor function to create a service.

      Parameters

      • name: string

        The name of the service.

      • constructor: any

        A class or function to instantiate.

      Returns Provider

    • Register a fixed value as a service.

      Parameters

      • name: string

        The name of the service.

      • val: any

        The value to use.

      Returns Provider