W3cubDocs

/Angular 12

@angular/core/global

entry-point

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.

Entry point exports

Functions

ng.applyChanges

Marks a component for check (in case of OnPush components) and synchronously performs change detection on the application this component belongs to.

ng.getComponent

Retrieves the component instance associated with a given DOM element.

ng.getContext

If inside an embedded view (e.g. *ngIf or *ngFor), retrieves the context of the embedded view that the element is part of. Otherwise retrieves the instance of the component whose view owns the element (in this case, the result is the same as calling getOwningComponent).

ng.getDirectiveMetadata

Returns the debug (partial) metadata for a particular directive or component instance. The function accepts an instance of a directive or component and returns the corresponding metadata.

ng.getDirectives

Retrieves directive instances associated with a given DOM node. Does not include component instances.

ng.getHostElement

Retrieves the host element of a component or directive instance. The host element is the DOM element that matched the selector of the directive.

ng.getInjector

Retrieves an Injector associated with an element, component or directive instance.

ng.getListeners

Retrieves a list of event listeners associated with a DOM element. The list does include host listeners, but it does not include event listeners defined outside of the Angular context (e.g. through addEventListener).

ng.getOwningComponent

Retrieves the component instance whose view contains the DOM element.

ng.getRootComponents

Retrieves all root components associated with a DOM element, directive or component instance. Root components are those which have been bootstrapped by Angular.

Structures

ComponentDebugMetadata

Partial metadata for a given component instance. This information might be useful for debugging purposes or tooling. Currently the following fields are available:

  • inputs
  • outputs
  • encapsulation
  • changeDetection
DirectiveDebugMetadata

Partial metadata for a given directive instance. This information might be useful for debugging purposes or tooling. Currently only inputs and outputs metadata is available.

Listener

Event listener configuration returned from getListeners.

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