@bmat-shared-libs/angular-dialog-service
v11.2.14
Published
This module provides a service to create dialogs with a dialog style.
Downloads
3
Readme
@bmat-shared-libs/angular-dialog-service
This module provides a service to create dialogs with a dialog style.
Creating dialogs
The main piece is the Angular service DialogService
. This
service provide a method
open(
embedComp: ComponentType<T> | TemplateRef<T>,
options: Partial<OpenDialogOption<E>> = {},
): DialogRef<T, E>
Calling this method will create the dialog and return a DialogRef
object:
export class DialogRef<CLOSE extends any = any, DATA extends any = any> {
public readonly data: DATA;
public readonly close: (value: CLOSE) => void;
public readonly valueChanges$: Observable<DialogAction<CLOSE>>;
public readonly dismiss: () => void;
public componentInstance: ComponentType<DATA> | null = null;
}
The DialogRef
is injected in the created element and can be used to close
(semantically close the dialog and send a result message) and dismiss
(close and do not send a message, like for example clicking a backdrop).
valueChanges$
streams the events Open, Close and Dismiss
with the related payload
Adding dialog components
Dialog components, not TemplateRef, need to be added to a NgModule.entryComponents
as they are dynamically created.