Product
Introducing SSO
Streamline your login process and enhance security by enabling Single Sign-On (SSO) on the Socket platform, now available for all customers on the Enterprise plan, supporting 20+ identity providers.
@ashetm/ng-dialog
Advanced tools
Readme
This library provide a unique UI of 3 types of dialog; alert, confirm and form.
Only Angular 14 and above are available.
You can install it with npm:
npm install @ashetm/ng-dialog
You only need to import DialogModule
through forRoot
static method.
...
import { DialogModule } from '@ashetm/ng-dialog';
...
@NgModule({
...
imports: [
...
DialogModule.forRoot(),
...
]
...
})
export class AppModule { }
The serviec to use is DialogService#openDialogAlert
, it's definition is:
openDialogAlert(
title: string,
body?: string,
{ closeLabel }?: Record<'closeLabel', string>
): DialogRef;
And it returns dialog reference DialogRef
, here is the exposed members:
type
returns an EDialogType
value with value of 'alert'getInstanceId()
returns a number
of instance idonBeforeClose(fn: () => boolean = () => true)
returns Observable<void>
and can pass a function handler to execute before closing, close the dialog alert if it returns true, else it stays openedExample:
constructor(
...
private readonly _dialogService: DialogService
...
) { }
openAlert(): void {
this._dialogService.openDialogAlert('Sample Title');
}
The serviec to use is DialogService#openDialogConfirm
, it's definition is:
openDialogConfirm(
title: string,
body?: string,
{ closeLabel, okLabel }?: Record<'closeLabel' | 'okLabel', string>
): DialogConfirmRef;
And it returns dialog reference DialogConfirmRef
, here is the exposed members:
type
returns an EDialogType
value with value of 'confirm'getInstanceId()
returns a number
of instance idonBeforeClose(fn: () => boolean = () => true)
returns Observable<void>
and can pass a function handler to execute before closing, close the dialog if it returns true, else it stays openedonBeforeDecision(fn: (decision: boolean) => boolean = (decision: boolean) => true)
returns Observable<boolean>
observable that returns the decision made by the user/client and can pass a function handler to execute before closing, close the dialog if it returns true etlse it stays openedExample:
constructor(
...
private readonly _dialogService: DialogService
...
) { }
openConfirm(): void {
this._dialogService.openDialogConfirm('Sample Title');
}
The service to use is DialogService#openDialogForm
, it's definition is:
openDialogForm<T extends TemplateRef<unknown>, U = any>(
title: string,
template: T,
{ closeLabel, okLabel }?: Record<'closeLabel' | 'okLabel', string>
): DialogFormRef<U>;
And it returns dialog reference DialogFormRef<U>
, here is the exposed members:
type
returns an EDialogType
value with value of 'alert'getInstanceId()
returns a number
of instance idonBeforeClose(fn: () => boolean = () => true)
returns Observable<void>
and can pass a function handler to execute before closing, close the dialog alert if it returns true, else it stays openedonBeforeData(fn: (data: U) => boolean = (_: U) => true)
returns Observable<U>
observable that returns the data of the form written by the user/client and can pass a function handler to execute before closing, close the dialog if it returns true etlse it stays openedIt also needs to tag ng-template
with the directive dialogFormBodyComponent
, that requires also to bind formGroup
directive. And also take reference of that ng-template
as DialogFormBodyComponent
.
Example:
...
<ng-template #dialogFormBodyComponent="DialogFormBodyComponent"
dialogFormBodyComponent
[formGroup]="formGroup">
Name: <input formControlName="name" />
</ng-template>
...
formGroup: FormGroup = new FormGroup({
name: new FormControl('Sample name')
});
...
constructor(
...
private readonly _dialogService: DialogService
...
) { }
openForm(template: DialogFormBodyComponentDirective): void {
this._dialogService.openDialogForm('Sample Title', template);
}
FAQs
This library provide a unique UI of 3 types of dialog; alert, confirm and form.
The npm package @ashetm/ng-dialog receives a total of 204 weekly downloads. As such, @ashetm/ng-dialog popularity was classified as not popular.
We found that @ashetm/ng-dialog demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
Streamline your login process and enhance security by enabling Single Sign-On (SSO) on the Socket platform, now available for all customers on the Enterprise plan, supporting 20+ identity providers.
Security News
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Security News
As cyber threats become more autonomous, AI-powered defenses are crucial for businesses to stay ahead of attackers who can exploit software vulnerabilities at scale.