averouiComponent playgroundv0.0.1

DynamicDialog

New

The right component, right when you need it. Open a dialog from code and bring the result back to your page.

Service APIDynamic contentTyped results

Choose something good

Load a component with the dialog service. Select a product to return its value to this page.

THE WORKSPACE EDIT

Small details. Better days.

A few thoughtful essentials to make this space yours.

A space for your next favoriteSelect a product to see it here.

Your next workspace favorite is waiting.

Customization

Reuse Dialog options for positioning, responsive widths, maximization and backdrop dismissal.

Passing data and inputs

Use injectable config.data for context, or inputValues to initialize the loaded component's Angular inputs. This example passes the selected product and a quantity of two.

Angular inputs
// ProductDetails declares product = input.required<Product>()
// and quantity = input(1).
this.dialogs.open(ProductDetails, {
  header: 'Product details',
  inputValues: { product: selectedProduct, quantity: 2 },
  maximizable: true,
});

Opening a dialog

Provide AvDialogService on the page and call open with a component and configuration. No dialog outlet is needed.

TypeScript
import { inject } from '@angular/core';
import { AvDialogService } from 'avero-ui';

// Add AvDialogService to this page's providers for automatic cleanup.
private readonly dialogs = inject(AvDialogService);

show() {
  const ref = this.dialogs.open<ProductPicker, { message: string }, Product>(
    ProductPicker, {
      header: 'Choose a product',
      width: '640px',
      breakpoints: { '768px': '92vw' },
      data: { message: 'Make yourself at home.' },
    },
  );
  ref.onClose.subscribe(product => {
    if (product) this.selected.set(product);
  });
}

Returning a result

Inject AvDynamicDialogRef in the loaded component. close(result) delivers the value to onClose; dismissing with Escape or the close button delivers undefined.

Dialog content
// Inside the dynamically loaded component:
readonly config = inject(AvDynamicDialogConfig<{ message: string }>);
readonly ref = inject(AvDynamicDialogRef<Product>);

select(product: Product) {
  this.ref.close(product);
}

API and lifecycle

Configuration. header, ariaLabel, inputId, width (480px), breakpoints, position (center), modal (true), closable (true), closeOnEscape (true), dismissableMask (false), maximizable (false), data and inputValues. Input keys use public Angular input names, including aliases.
Reference. close(result?) closes once and emits onClose. destroy() disposes without a result. onDestroy runs for either path; both observable streams complete. A locally provided service disposes its dialogs when the page is destroyed.
Accessibility and SSR. The underlying Dialog supplies modal focus containment, Escape support and focus restoration. Give every dialog a header or ariaLabel. Opening on the server is inert; open from browser interactions after hydration.
Avero UI Designed to fit your application.