W3cubDocs

/Angular

@angular/core

package

Implements Angular's core functionality, low-level services, and utilities.

  • Defines the class infrastructure for components, view hierarchies, change detection, rendering, and event handling.

  • Defines the decorators that supply metadata and context for Angular constructs.

  • Defines infrastructure for dependency injection (DI), internationalization (i18n), and various testing and debugging facilities.

Entry points

Primary

@angular/core

Implements Angular's core functionality, low-level services, and utilities.

Secondary

@angular/core/global

Exposes a set of functions in the global namespace which are useful for debugging the current state of your application. These functions are exposed via the global ng "namespace" variable automatically when you import from @angular/core and run your application in development mode. These functions are not exposed when the application runs in a production mode.

@angular/core/rxjs-interop

Includes utilities related to using the RxJS library in conjunction with Angular's signal-based reactivity system.

@angular/core/testing

Provides infrastructure for testing Angular core functionality.

Primary entry point exports

NgModules

ApplicationModule

Re-exported by BrowserModule, which is included automatically in the root AppModule when you create a new app with the CLI new command. Eagerly injects ApplicationRef to instantiate it.

Classes

ApplicationInitStatus

A class that reflects the state of running APP_INITIALIZER functions.

ApplicationRef

A reference to an Angular application running on a page.

ChangeDetectorRef

Base class that provides change detection functionality. A change-detection tree collects all views that are to be checked for changes. Use the methods to add and remove views from the tree, initiate change-detection, and explicitly mark views as dirty, meaning that they have changed and need to be re-rendered.

Compiler

Deprecated: Ivy JIT mode doesn't require accessing this symbol. See JIT API changes due to ViewEngine deprecation for additional context.

Low-level service for running the angular compiler during runtime to create ComponentFactorys, which can later be used to create and render a Component instance.

CompilerFactory

Deprecated: Ivy JIT mode doesn't require accessing this symbol. See JIT API changes due to ViewEngine deprecation for additional context.

A factory for creating a Compiler

ComponentFactory

Deprecated: Angular no longer requires Component factories. Please use other APIs where Component class can be used directly.

Base class for a factory that can create a component dynamically. Instantiate a factory for a given type of component with resolveComponentFactory(). Use the resulting ComponentFactory.create() method to create a component of that type.

ComponentFactoryResolver

Deprecated: Angular no longer requires Component factories. Please use other APIs where Component class can be used directly.

A simple registry that maps Components to generated ComponentFactory classes that can be used to create instances of components. Use to obtain the factory for a given component type, then use the factory's create() method to create a component of that type.

ComponentRef

Represents a component created by a ComponentFactory. Provides access to the component instance and related objects, and provides the means of destroying the instance.

DebugElement
DebugEventListener
DebugNode
DefaultIterableDiffer

Deprecated: v4.0.0 - Should not be part of public API.

DestroyRef

DestroyRef lets you set callbacks to run for any cleanup or destruction behavior. The scope of this destruction depends on where DestroyRef is injected. If DestroyRef is injected in a component or directive, the callbacks run when that component or directive is destroyed. Otherwise the callbacks run when a corresponding injector is destroyed.

ElementRef

A wrapper around a native element inside of a View.

EmbeddedViewRef

Represents an Angular view in a view container. An embedded view can be referenced from a component other than the hosting component whose template defines it, or it can be defined independently by a TemplateRef.

EnvironmentInjector

An Injector that's part of the environment injector hierarchy, which exists outside of the component tree.

ErrorHandler

Provides a hook for centralized exception handling.

EventEmitter

Use in components with the @Output directive to emit custom events synchronously or asynchronously, and register handlers for those events by subscribing to an instance.

InjectionToken

Creates a token that can be used in a DI Provider.

Injector

Concrete injectors implement this interface. Injectors are configured with providers that associate dependencies of various types with injection tokens.

IterableDiffers

A repository of different iterable diffing strategies used by NgFor, NgClass, and others.

KeyValueDiffers

A repository of different Map diffing strategies used by NgClass, NgStyle, and others.

ModuleWithComponentFactories

Deprecated: Ivy JIT mode doesn't require accessing this symbol. See JIT API changes due to ViewEngine deprecation for additional context.

Combination of NgModuleFactory and ComponentFactories.

NgModuleFactory

Deprecated: This class was mostly used as a part of ViewEngine-based JIT API and is no longer needed in Ivy JIT mode. See JIT API changes due to ViewEngine deprecation for additional context. Angular provides APIs that accept NgModule classes directly (such as PlatformRef.bootstrapModule and createNgModule), consider switching to those APIs instead of using factory-based ones.

NgModuleRef

Represents an instance of an NgModule created by an NgModuleFactory. Provides access to the NgModule instance and related objects.

NgProbeToken

A token for third-party components that can register themselves with NgProbe.

NgZone

An injectable service for executing work inside or outside of the Angular zone.

PlatformRef

The Angular platform is the entry point for Angular on a web page. Each page has exactly one platform. Services (such as reflection) which are common to every Angular application running on the page are bound in its scope. A page's platform is initialized implicitly when a platform is created using a platform factory such as PlatformBrowser, or explicitly by calling the createPlatform() function.

Query

Base class for query metadata.

QueryList

An unmodifiable list of items that Angular keeps up to date when the state of the application changes.

Renderer2

Extend this base class to implement custom rendering. By default, Angular renders a template into DOM. You can use custom rendering to intercept rendering calls, or to render to something other than DOM.

RendererFactory2

Creates and initializes a custom renderer that implements the Renderer2 base class.

Sanitizer

Sanitizer is used by the views to sanitize potentially dangerous values.

SimpleChange

Represents a basic change from a previous to a new value for a single property on a directive instance. Passed as a value in a SimpleChanges object to the ngOnChanges hook.

TemplateRef

Represents an embedded template that can be used to instantiate embedded views. To instantiate embedded views based on a template, use the ViewContainerRef method createEmbeddedView().

Testability

The Testability service provides testing hooks that can be accessed from the browser.

TestabilityRegistry

A global registry of Testability instances for specific elements.

TransferState

A key value store that is transferred from the application on the server side to the application on the client side.

Type

Represents a type that a Component or other object is instances of.

Version

Represents the version of Angular

ViewContainerRef

Represents a container where one or more views can be attached to a component.

ViewRef

Represents an Angular view.

Decorators

Attribute

Parameter decorator for a directive constructor that designates a host-element attribute whose value is injected as a constant string literal.

Component

Decorator that marks a class as an Angular component and provides configuration metadata that determines how the component should be processed, instantiated, and used at runtime.

ContentChild

Property decorator that configures a content query.

ContentChildren

Property decorator that configures a content query.

Directive

Decorator that marks a class as an Angular directive. You can define your own directives to attach custom behavior to elements in the DOM.

Host

Parameter decorator on a view-provider parameter of a class constructor that tells the DI framework to resolve the view by checking injectors of child elements, and stop when reaching the host element of the current component.

HostBinding

Decorator that marks a DOM property as a host-binding property and supplies configuration metadata. Angular automatically checks host property bindings during change detection, and if a binding changes it updates the host element of the directive.

HostListener

Decorator that declares a DOM event to listen for, and provides a handler method to run when that event occurs.

Inject

Parameter decorator on a dependency parameter of a class constructor that specifies a custom provider of the dependency.

Injectable

Decorator that marks a class as available to be provided and injected as a dependency.

Input

Decorator that marks a class field as an input property and supplies configuration metadata. The input property is bound to a DOM property in the template. During change detection, Angular automatically updates the data property with the DOM property's value.

NgModule

Decorator that marks a class as an NgModule and supplies configuration metadata.

Optional

Parameter decorator to be used on constructor parameters, which marks the parameter as being an optional dependency. The DI framework provides null if the dependency is not found.

Output

Decorator that marks a class field as an output property and supplies configuration metadata. The DOM property bound to the output property is automatically updated during change detection.

Pipe

Decorator that marks a class as pipe and supplies configuration metadata.

Self

Parameter decorator to be used on constructor parameters, which tells the DI framework to start dependency resolution from the local injector.

SkipSelf

Parameter decorator to be used on constructor parameters, which tells the DI framework to start dependency resolution from the parent injector. Resolution works upward through the injector hierarchy, so the local injector is not checked for a provider.

ViewChild

Property decorator that configures a view query. The change detector looks for the first element or the directive matching the selector in the view DOM. If the view DOM changes, and a new child matches the selector, the property is updated.

ViewChildren

Property decorator that configures a view query.

Functions

asNativeElements
assertInInjectionContext

Asserts that the current stack frame is within an injection context and has access to inject.

assertPlatform

Checks that there is currently a platform that contains the given token as a provider.

booleanAttribute

Transforms a value (typically a string) to a boolean. Intended to be used as a transform function of an input.

computed

Create a computed Signal which derives a reactive value from an expression.

createComponent

Creates a ComponentRef instance based on provided component type and a set of options.

createEnvironmentInjector

Create a new environment injector.

createNgModule

Returns a new NgModuleRef instance based on the NgModule class and parent injector provided.

createPlatform

Creates a platform. Platforms must be created on launch using this function.

createPlatformFactory

Creates a factory for a platform. Can be used to provide or override Providers specific to your application's runtime needs, such as PLATFORM_INITIALIZER and PLATFORM_ID.

destroyPlatform

Destroys the current Angular platform and all Angular applications on the page. Destroys all modules and listeners registered with the platform.

effect

Create a global Effect for the given reactive function.

enableProdMode

Disable Angular's development mode, which turns off assertions and other checks within the framework.

forwardRef

Allows to refer to references which are not yet defined.

getDebugNode
getModuleFactory

Deprecated: Use getNgModuleById instead.

Returns the NgModuleFactory with the given id (specified using @NgModule.id field), if it exists and has been loaded. Factories for NgModules that do not specify an id cannot be retrieved. Throws if an NgModule cannot be found.

getNgModuleById

Returns the NgModule class with the given id (specified using @NgModule.id field), if it exists and has been loaded. Classes for NgModules that do not specify an id cannot be retrieved. Throws if an NgModule cannot be found.

getPlatform

Returns the current platform.

importProvidersFrom

Collects providers from all NgModules and standalone components, including transitively imported ones.

inject

Injects a token from the currently active injector. inject is only supported during instantiation of a dependency by the DI system. It can be used during:

  • Construction (via the constructor) of a class being instantiated by the DI system, such as an @Injectable or @Component.
  • In the initializer for fields of such classes.
  • In the factory function specified for useFactory of a Provider or an @Injectable.
  • In the factory function specified for an InjectionToken.
isDevMode

Returns whether Angular is in development mode.

isSignal

Checks if the given value is a reactive Signal.

isStandalone

Checks whether a given Component, Directive or Pipe is marked as standalone. This will return false if passed anything other than a Component, Directive, or Pipe class See this guide for additional information:

makeEnvironmentProviders

Wrap an array of Providers into EnvironmentProviders, preventing them from being accidentally referenced in `@Component in a component injector.

makeStateKey

Create a StateKey<T> that can be used to store value of type T with TransferState.

mergeApplicationConfig

Merge multiple application configurations from left to right.

numberAttribute

Transforms a value (typically a string) to a number. Intended to be used as a transform function of an input.

provideZoneChangeDetection

Provides NgZone-based change detection for the application bootstrapped using bootstrapApplication.

reflectComponentType

Creates an object that allows to retrieve component metadata.

resolveForwardRef

Lazily retrieves the reference value from a forwardRef.

runInInjectionContext

Runs the given function in the context of the given Injector.

setTestabilityGetter

Set the GetTestability implementation used by the Angular testing framework.

signal

Create a Signal that can be set or updated directly.

untracked

Execute an arbitrary function in a non-reactive (non-tracking) context. The executed function can, optionally, return a value.

Structures

AbstractType

Represents an abstract class T, if applied to a concrete class it would stop being instantiable.

AfterContentChecked

A lifecycle hook that is called after the default change detector has completed checking all content of a directive. It will run after the content has been checked and most of the time it's during a change detection cycle.

AfterContentInit

A lifecycle hook that is called after Angular has fully initialized all content of a directive. It will run only once when the projected content is initialized. Define an ngAfterContentInit() method to handle any additional initialization tasks.

AfterViewChecked

A lifecycle hook that is called after the default change detector has completed checking a component's view for changes.

AfterViewInit

A lifecycle hook that is called after Angular has fully initialized a component's view. Define an ngAfterViewInit() method to handle any additional initialization tasks.

ApplicationConfig

Set of config options available during the application bootstrap operation.

BootstrapOptions

Provides additional options to the bootstrapping process.

ChangeDetectionStrategy

The strategy that the default change detector uses to detect changes. When set, takes effect the next time change detection is triggered.

ClassProvider

Configures the Injector to return an instance of useClass for a token.

ClassSansProvider

Configures the Injector to return a value by invoking a useClass function. Base for ClassProvider decorator.

ComponentMirror

An interface that describes the subset of component metadata that can be retrieved using the reflectComponentType function.

ConstructorProvider

Configures the Injector to return an instance of a token.

ConstructorSansProvider

Configures the Injector to return an instance of a token.

CreateComputedOptions

Options passed to the computed creation function.

CreateEffectOptions

Options passed to the effect function.

CreateSignalOptions

Options passed to the signal creation function.

DoBootstrap

Hook for manual bootstrapping of the application instead of using bootstrap array in @NgModule annotation. This hook is invoked only when the bootstrap array is empty or not provided.

DoCheck

A lifecycle hook that invokes a custom change-detection function for a directive, in addition to the check performed by the default change-detector.

EffectRef

A global reactive effect, which can be manually destroyed.

ExistingProvider

Configures the Injector to return a value of another useExisting token.

ExistingSansProvider

Configures the Injector to return a value of another useExisting token.

FactoryProvider

Configures the Injector to return a value by invoking a useFactory function.

FactorySansProvider

Configures the Injector to return a value by invoking a useFactory function.

ForwardRefFn

An interface that a function passed into forwardRef has to implement.

GetTestability

Adapter interface for retrieving the Testability service associated for a particular context.

InjectFlags

Deprecated: use an options object for inject instead.

Injection flags for DI.

InjectOptions

Type of the options argument to inject.

InjectableType

A Type which has a ɵprov: ɵɵInjectableDeclaration static field.

InjectorType

A type which has an InjectorDef static field.

IterableChangeRecord

Record representing the item change information.

IterableChanges

An object describing the changes in the Iterable collection since last time IterableDiffer#diff() was invoked.

IterableDiffer

A strategy for tracking changes over time to an iterable. Used by NgForOf to respond to changes in an iterable by effecting equivalent changes in the DOM.

IterableDifferFactory

Provides a factory for IterableDiffer.

KeyValueChangeRecord

Record representing the item change information.

KeyValueChanges

An object describing the changes in the Map or {[k:string]: string} since last time KeyValueDiffer#diff() was invoked.

KeyValueDiffer

A differ that tracks changes made to an object over time.

KeyValueDifferFactory

Provides a factory for KeyValueDiffer.

MissingTranslationStrategy

Use this enum at bootstrap as an option of bootstrapModule to define the strategy that the compiler should use in case of missing translations:

  • Error: throw if you have missing translations.
  • Warning (default): show a warning in the console and/or shell.
  • Ignore: do nothing.
ModuleWithProviders

A wrapper around an NgModule that associates it with providers. Usage without a generic type is deprecated.

NgZoneOptions

Used to configure event and run coalescing with provideZoneChangeDetection.

OnChanges

A lifecycle hook that is called when any data-bound property of a directive changes. Define an ngOnChanges() method to handle the changes.

OnDestroy

A lifecycle hook that is called when a directive, pipe, or service is destroyed. Use for any custom cleanup that needs to occur when the instance is destroyed.

OnInit

A lifecycle hook that is called after Angular has initialized all data-bound properties of a directive. Define an ngOnInit() method to handle any additional initialization tasks.

PipeTransform

An interface that is implemented by pipes in order to perform a transformation. Angular invokes the transform method with the value of a binding as the first argument, and any parameters as the second argument in list form.

Predicate

A boolean-valued function over a value, possibly including context information regarding that value's position in an array.

RendererStyleFlags2

Flags for renderer-specific style modifiers.

RendererType2

Used by RendererFactory2 to associate custom rendering data and styles with a rendering implementation.

SchemaMetadata

A schema definition associated with an NgModule.

SecurityContext

A SecurityContext marks a location that has dangerous security implications, e.g. a DOM property like innerHTML that could cause Cross Site Scripting (XSS) security bugs when improperly handled.

SimpleChanges

A hashtable of changes represented by SimpleChange objects stored at the declared property name they belong to on a Directive or Component. This is the type passed to the ngOnChanges hook.

StaticClassProvider

Configures the Injector to return an instance of useClass for a token.

StaticClassSansProvider

Configures the Injector to return an instance of useClass for a token. Base for StaticClassProvider decorator.

TrackByFunction

A function optionally passed into the NgForOf directive to customize how NgForOf uniquely identifies items in an iterable.

TypeDecorator

An interface implemented by all Angular type decorators, which allows them to be used as decorators as well as Angular syntax.

TypeProvider

Configures the Injector to return an instance of Type when `Type' is used as the token.

ValueProvider

Configures the Injector to return a value for a token.

ValueSansProvider

Configures the Injector to return a value for a token. Base for ValueProvider decorator.

ViewEncapsulation

Defines the CSS styles encapsulation policies for the Component decorator's encapsulation option.

WritableSignal

A Signal with a value that can be mutated via a setter interface.

Elements

<ng-container>

A special element that can hold structural directives without adding new elements to the DOM.

<ng-content>

The <ng-content> element specifies where to project content inside a component template.

<ng-template>

Angular's <ng-template> element defines a template that is not rendered by default.

Types

ANIMATION_MODULE_TYPE

A DI token that indicates which animations module has been loaded.

APP_BOOTSTRAP_LISTENER

A DI token that provides a set of callbacks to be called for every component that is bootstrapped.

APP_ID

A DI token representing a string ID, used primarily for prefixing application attributes and CSS styles when ViewEncapsulation#Emulated is being used.

APP_INITIALIZER

A DI token that you can use to provide one or more initialization functions.

COMPILER_OPTIONS

Token to provide CompilerOptions in the platform injector.

CSP_NONCE

Token used to configure the Content Security Policy nonce that Angular will apply when inserting inline styles. If not provided, Angular will look up its value from the ngCspNonce attribute of the application root node.

CUSTOM_ELEMENTS_SCHEMA

Defines a schema that allows an NgModule to contain the following:

  • Non-Angular elements named with dash case (-).
  • Element properties named with dash case (-). Dash case is the naming convention for custom elements.
CompilerOptions

Options for creating a compiler.

DEFAULT_CURRENCY_CODE

Provide this token to set the default currency code your application uses for CurrencyPipe when there is no currency code passed into it. This is only used by CurrencyPipe and has no relation to locale currency. Defaults to USD if not configured.

ENVIRONMENT_INITIALIZER

A multi-provider token for initialization functions that will run upon construction of an environment injector.

EffectCleanupFn

An effect can, optionally, register a cleanup function. If registered, the cleanup is executed before the next effect run. The cleanup function makes it possible to "cancel" any work that the previous effect run might have started.

EnvironmentProviders

Encapsulated Providers that are only accepted during creation of an EnvironmentInjector (e.g. in an NgModule).

INJECTOR

An InjectionToken that gets the current Injector for createInjector()-style injectors.

ImportProvidersSource

A source of providers for the importProvidersFrom function.

ImportedNgModuleProviders

Deprecated: replaced by EnvironmentProviders

Providers that were imported from NgModules via the importProvidersFrom function.

InjectableProvider

Injectable providers used in @Injectable decorator.

LOCALE_ID

Provide this token to set the locale of your application. It is used for i18n extraction, by i18n pipes (DatePipe, I18nPluralPipe, CurrencyPipe, DecimalPipe and PercentPipe) and by ICU expressions.

NO_ERRORS_SCHEMA

Defines a schema that allows any property on any element.

NgIterable

A type describing supported iterable types.

PACKAGE_ROOT_URL

A DI token that indicates the root directory of the application

PLATFORM_ID

A token that indicates an opaque platform ID.

PLATFORM_INITIALIZER

A function that is executed when a platform is initialized.

Provider

Describes how the Injector should be configured.

ProviderToken

Token that can be used to retrieve an instance from an injector or through a query.

Signal

A reactive value which notifies consumers of any changes.

StateKey

A type-safe key to use with TransferState.

StaticProvider

Describes how an Injector should be configured as static (that is, without reflection). A static provider provides tokens to an injector for various types of dependencies.

TRANSLATIONS

Use this token at bootstrap to provide the content of your translation file (xtb, xlf or xlf2) when you want to translate your application in another language.

TRANSLATIONS_FORMAT

Provide this token at bootstrap to set the format of your TRANSLATIONS: xtb, xlf or xlf2.

ValueEqualityFn

A comparison function which can determine if two values are equal.

createNgModuleRef

Deprecated: Use createNgModule instead.

The createNgModule function alias for backwards-compatibility. Please avoid using it directly and use createNgModule instead.

defineInjectable

Deprecated: in v8, delete after v10. This API should be used only by generated code, and that code should now use ɵɵdefineInjectable instead.

platformCore

This platform has to be included in any other platform

© 2010–2023 Google, Inc.
Licensed under the Creative Commons Attribution License 4.0.
https://angular.io/api/core