File

overlay/src/overlay/overlay.ref.ts

Description

The OverlayRef is a reference to an overlay that has been created using the OverlayService.

See OverlayService

Index

Methods

Methods

clearCloseCallback
clearCloseCallback()

Removes the custom close callback

Returns : void
close
close(result?: any)

Closes the overlay.

The result can be accessed in the overlay component as follows:

Example :
const overlayRef = this.overlayService.open(OverlayComponent);

overlayRef.onClose.subscribe((myString) => {
   console.log('[OverlayDemo] onClose Subscription: ', myString);
 });
Parameters :
Name Type Optional Description
result any Yes

The result to be passed to the onClose observable.

The result can be accessed in the overlay component as follows:

Example :
const overlayRef = this.overlayService.open(OverlayComponent);

overlayRef.onClose.subscribe((myString) => {
console.log('[OverlayDemo] onClose Subscription: ', myString);
});
Returns : void
destroy
destroy()

Destroys the overlay.

This method is called by the OverlayService when the overlay is destroyed and does not need be called by the consumer.

Returns : void
Public getDisplayedComponentInstance
getDisplayedComponentInstance()
Type parameters :
  • C

Returns a reference to the component displayed in the overlay.

Example :
const componentRef: ConfirmationComponent = this.overlayRef?.getDisplayedComponentInstance<ConfirmationComponent>();
Returns : C
hide
hide()

Hides the overlay.

This method is called by the OverlayService when the overlay is hidden behind another overlay and does not need be called by the consumer.

Returns : void
registerCloseCallback
registerCloseCallback(callback: () => void)

Registers a custom close callback.

The callback must return a promise that resolves to a boolean value.

Can be used to show the user a confirmation dialog before closing the overlay, e.g. if the form is invalid

If the promise resolves to true, the overlay will be closed. If the promise resolves to false, the overlay will not be closed.

Example :
overlayRef.registerCloseCallback(() => {
  return new Promise((resolve, _reject) => {
    resolve(true);
   }) as Promise<boolean>;
});
Parameters :
Name Type Optional Description
callback function No

The callback to be called when the overlay is closed.

The callback must return a promise that resolves to a boolean value.

Can be used to show the user a confirmation dialog before closing the overlay, e.g. if the form is invalid

If the promise resolves to true, the overlay will be closed. If the promise resolves to false, the overlay will not be closed.

Example :
overlayRef.registerCloseCallback(() => {
return new Promise((resolve, _reject) => {
resolve(true);
}) as Promise<boolean>;
});
Returns : void
reveal
reveal()

Reveals the overlay.

This method is called by the OverlayService when the overlay is revealed by closing the topmost overlay and does not need be called by the consumer.

Returns : void

results matching ""

    No results matching ""