ApplicationRef class Core

A reference to an Angular application running on a page.

An ApplicationRef is created when an AngularDart application is bootstrapped via runApp. It manages the root component(s), triggers change detection, and handles application-level lifecycle events.

The application reference is responsible for:

  • Bootstrapping root components with bootstrap.
  • Running change detection on each microtask via tick.
  • Handling uncaught exceptions through ExceptionHandler.
  • Disposing of the application and all its components via dispose.

For more about Angular applications, see the documentation for runApp.

See also:

Properties

hashCode int
The hash code for this object.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

bootstrap<T extends Object>(ComponentFactory<T> componentFactory) ComponentRef<T>
Bootstrap a new component at the root level of the application.
dispose() → void
Dispose of this application and all of its components.
handleUncaughtException(Object error, [StackTrace? trace, String? reason]) → void
Forwards an error and trace to the user's error handler.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
registerChangeDetector(ChangeDetectorRef detector) → void
Registers a change detector with this host for automatic detection.
inherited
registerDisposeListener(void listener()) → void
Register a listener to be called when the application is disposed.
reportViewException(View view, Object error, [StackTrace? trace]) → void
Disables the view as an error, and forwards to reportException.
inherited
run<R>(FutureOr<R> callback()) FutureOr<R>
Runs the given callback in the zone and returns the result of that call.
inherited
runInZone<R>(R callback()) → R
Executes the callback function within the current NgZone.
tick() → void
Runs a change detection pass on all registered root components.
inherited
toString() String
A string representation of this object.
inherited
unregisterChangeDetector(ChangeDetectorRef detector) → void
Removes a change detector from this host (no longer checked).
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited