Dialog
Overlay[atlasDialogBody][atlasDialogClose][atlasDialogDescription][atlasDialogFooter][atlasDialogHeader][atlasDialogTitle]atlas-confirm-dialogatlas-dialogExamples
Dialog
Bind open and handle (closed) ; compose the panel with header, title, description and footer.
Confirm with the service
AtlasDialogService.confirm() and deleteConfirm() open a ready-made confirm dialog and resolve to true or false .
Typed dialog from code
The dialog declares its result and data with injectAtlasDialogRef<Result, Data>() ; injectAtlasDialog().open() infers both, requires the data and returns a typed result . The title names the dialog on its own, and atlasDialogClose cancels.
Open a template
open() also takes an ng-template : it receives the ref as let-ref and the data as let-data="data" . Type the TemplateRef with AtlasDialogTemplateContext<Result, Data> and the call is typed like a component dialog.
Sizes and defaults
size sets the width: sm , md (default), lg , xl or full . provideAtlasDialogDefaults() in a component's providers sets defaults for the dialogs it opens with injectAtlasDialog() ; here every dialog is lg unless the call says otherwise.
Long content
The card is never taller than the screen, whatever its size . Wrap the content between the header and the footer in atlasDialogBody : it scrolls, and the title and the footer actions stay in view.
API
Generated from the library source, so it always matches the code.
AtlasDialogCloseDirective [atlasDialogClose]
| Input | Type | Default | Description |
|---|---|---|---|
| atlasDialogClose | unknown | undefined | undefined dismisses instead. |
| type | 'button' | 'submit' | 'reset' | 'button' | type of the host <button> (ignored on other elements). Default: 'button' , so it never submits a form. |
AtlasDialogComponent atlas-dialog
| Input | Type | Default | Description |
|---|---|---|---|
| open required | boolean | — | false . |
| class | string | '' | cn() ; yours win on conflicts. |
| size | AtlasDialogSize | 'md' | 'md' |
| closeLabel | string | undefined | undefined | dialog.close text. |
| Output | Payload | Description |
|---|---|---|
| closed | void | atlasDialogClose or CDK closing on navigation: set open to false in the handler. |
AtlasDialogHeaderComponent [atlasDialogHeader]
| Input | Type | Default | Description |
|---|---|---|---|
| class | string | '' | cn() ; yours win on conflicts. |
AtlasDialogTitleComponent [atlasDialogTitle]
| Input | Type | Default | Description |
|---|---|---|---|
| class | string | '' | cn() ; yours win on conflicts. |
| id | string | '' | <dialog id>-title . The dialog's aria-labelledby points at it. |
AtlasDialogDescriptionComponent [atlasDialogDescription]
| Input | Type | Default | Description |
|---|---|---|---|
| class | string | '' | cn() ; yours win on conflicts. |
| id | string | '' | <dialog id>-desc . The dialog's aria-describedby points at it. |
AtlasDialogBodyComponent [atlasDialogBody]
| Input | Type | Default | Description |
|---|---|---|---|
| class | string | '' | cn() ; yours win on conflicts. |
AtlasDialogFooterComponent [atlasDialogFooter]
| Input | Type | Default | Description |
|---|---|---|---|
| class | string | '' | cn() ; yours win on conflicts. |
AtlasDialogRef<R = unknown, D = unknown>class
R and its data D . The dialog component declares both with injectAtlasDialogRef<R, D>() on a public property; AtlasDialogService.open() reads them from there (ADR 0028).
| Member | Description |
|---|---|
| readonly data: D | data passed to open() . |
| readonly result: Promise<AtlasDialogResult<R>> | |
| get id: string | |
| close(...[value]: CloseArgs<R>): void | |
| dismiss(reason: AtlasDialogDismissReason = 'cancel'): void | |
| afterClosed(): Observable<R | undefined> | close() , or undefined when dismissed. Built on result , so a subscription made after the dialog closed still receives it. |
AtlasDialogServiceservice
@angular/cdk/dialog , which provides the backdrop, focus trap and focus restore, scroll blocking, and Escape delivered to the topmost dialog only. Prefer injectAtlasDialog() : its dialogs are created under the caller's injector, so they see the providers of the component that opened them.
| Member | Description |
|---|---|
| open<C, R = AtlasDialogResultOf<C>, D = AtlasDialogDataOf<C>>(content: Type<C> | TemplateRef<AtlasDialogTemplateContext<R, D>>, ...[config = {}]: AtlasDialogConfigArgs<NoInfer<D>>): AtlasDialogRef<R, D> | R and data D come from the public property it assigns injectAtlasDialogRef<R, D>() to. - **Template:** R and D come from its TemplateRef<AtlasDialogTemplateContext<R, D>> type; it receives the ref as $implicit and the data as data . data is required when D does not accept undefined . |
| confirm(options: ConfirmOptions): Promise<boolean> | true (confirmed) or false (cancelled). |
| deleteConfirm(options: DeleteConfirmOptions): Promise<boolean> | true (confirmed) or false (cancelled). |
Functions
| Function | Description |
|---|---|
| createAtlasDialogTesting<R = unknown, D = unknown>(...[options = {}]: undefined extends D ? [options?: { data?: D }] : [options: { data: D }]): AtlasDialogTesting<R, D> | AtlasDialogRef (and the context atlasDialogClose , atlasDialogTitle and atlasDialogDescription use) backed by a stand-in for the CDK ref, so close() / dismiss() resolve ref.result and nothing renders in an overlay. Like open() , it requires data when D does not accept undefined . |
| injectAtlasDialog(): AtlasDialogService | |
| injectAtlasDialogRef<R = void, D = void>(): AtlasDialogRef<R, D> | R and data D . Assign it to a public property ( @atlas/dialog-ref-public ): open() infers both types from it. |
| provideAtlasDialogDefaults(defaults: AtlasDialogDefaults): Provider | open() . In the application providers they apply everywhere; in a component's providers they apply to dialogs that component opens with injectAtlasDialog() . |
Types
AtlasDialogConfig
AtlasDialogService.open() .
| Property | Type | Description |
|---|---|---|
| data? | D | injectAtlasDialogRef<R, D>().data . Required when the dialog's D does not accept undefined . |
| size? | AtlasDialogSize | 'md' , or the size of provideAtlasDialogDefaults() |
| panelClass? | string | panelClass ) |
| disableClose? | boolean | |
| width? deprecated | string | size width. |
| role? | 'dialog' | 'alertdialog' | dialog (default), or alertdialog for urgent interruptions. |
| ariaLabelledBy? | string | atlasDialogTitle inside it. |
| ariaDescribedBy? | string | atlasDialogDescription inside it. |
| injector? | Injector | injectAtlasDialog() , and to the root injector with inject(AtlasDialogService) . |
AtlasDialogConfigArgs
undefined ; otherwise it is required and carries data .
type AtlasDialogConfigArgs = undefined extends D ? [config?: AtlasDialogConfig<D>] : [config: AtlasDialogConfig<D> & { data: D }]AtlasDialogDataOf
injectAtlasDialogRef<R, D>() ; unknown when it declares none.
type AtlasDialogDataOf = [DialogRefOf<C>] extends [never] ? unknown : DialogRefOf<C> extends AtlasDialogRef<unknown, infer D> ? D : unknownAtlasDialogDefaults
AtlasDialogService.open() ; each open() config wins over them.
| Property | Type | Description |
|---|---|---|
| size? | AtlasDialogSize | 'md' |
| disableClose? | boolean | false |
| panelClass? | string |
AtlasDialogDismissReason
escape , a backdrop click, cancel (the default of dismiss() ), or external (CDK closed it: navigation, Dialog.closeAll() ).
type AtlasDialogDismissReason = 'escape' | 'backdrop' | 'cancel' | 'external'AtlasDialogResult
type AtlasDialogResult = | { readonly type: 'closed'; readonly value: R } | { readonly type: 'dismissed'; readonly reason: AtlasDialogDismissReason }AtlasDialogResultOf
injectAtlasDialogRef<R, D>() ; unknown when it declares none.
type AtlasDialogResultOf = [DialogRefOf<C>] extends [never] ? unknown : DialogRefOf<C> extends AtlasDialogRef<infer R, unknown> ? R : unknownAtlasDialogSize
md is the default; full covers the viewport.
type AtlasDialogSize = 'sm' | 'md' | 'lg' | 'xl' | 'full'AtlasDialogTemplateContext
$implicit ( let-ref ) and the data as data ( let-data="data" ).
| Property | Type | Description |
|---|---|---|
| $implicit | AtlasDialogRef<R, D> | |
| data | D |
AtlasDialogTesting
| Property | Type | Description |
|---|---|---|
| ref | AtlasDialogRef<R, D> | await ref.result to assert how the component closed it. |
| providers | Provider[] | TestBed.configureTestingModule({ providers }) (or the component's providers). |
ConfirmDialogData
| Property | Type | Description |
|---|---|---|
| title | string | |
| message | string | |
| confirmLabel? | string | |
| cancelLabel? | string | |
| destructive? | boolean | |
| icon? | string |
ConfirmOptions
type ConfirmOptions = ConfirmDialogDataDeleteConfirmOptions
| Property | Type | Description |
|---|---|---|
| title? | string | |
| message | string | |
| confirmLabel? | string | |
| cancelLabel? | string | |
| icon? | string |
DialogOptions deprecated
type DialogOptions = AtlasDialogConfig<D>