![require(esm) Backported to Node.js 20, Paving the Way for ESM-Only Packages](https://cdn.sanity.io/images/cgdhsj6q/production/be8ab80c8efa5907bc341c6fefe9aa20d239d890-1600x1097.png?w=400&fit=max&auto=format)
Security News
require(esm) Backported to Node.js 20, Paving the Way for ESM-Only Packages
require(esm) backported to Node.js 20, easing the transition to ESM-only packages and reducing complexity for developers as Node 18 nears end-of-life.
dialog-service
Advanced tools
Reactive Angular modal dialogs. Create alert, confirmation, progress and form based dialogs without writing component templates.
Reactive Angular modal dialogs. Create alert, confirmation, progress and form based dialogs without writing component templates.
withAlert()
, withProgress()
, withConfirm()
, withForm()
.Before installing this library, you need an existing Angular application configured with Angular Material (or Material Web Components for Angular).
Add dialog-service
as an NPM dependency with npm install dialog-service
.
Import this module to your application:
import { MatDialogServiceModule } from 'dialog-service'
// import { MdcDialogServiceModule } from 'dialog-service'
@NgModule({
...
imports: [
// --- if you are using Angular Material
MatDialogServiceModule
// --- if you are using Material Web Components for Angular
// MdcDialogServiceModule
]
...
})
export class AppModule {
}
DialogService
to your components and call the withXxx()
functions.@Component()
export class AppComponent {
constructor (private dialogService: DialogService) {
}
doDemo() {
// no need to subscribe if not piping with additional operators
this.dialogService.withAlert('Hello!')
}
doDemo2() {
// need to subscribe for piped operators to run
this.dialogService.withAlert('Get ready...').pipe(
concatMap(() => this.dialogService.withAlert('Go!'))
).subscribe()
}
}
The DialogService class exposes functions used to create alert, confirmation, progress and form based dialogs.
withAlert (
title: string,
options?: {
content?: string
acceptButton?: string // defaults to 'OK'
}
): Observable<boolean>
Displays an alert dialog with optional title and content. User clicks OK to close the dialog.
Returns true after the dialog is closed. TODO: provide option to cancel the alert and return false.
withConfirm (
title?: string, // defaults to 'Confirm?'
options?: {
content?: string
acceptButton?: string // defaults to 'Yes'
cancelButton?: string // defaults to 'No
cancelMessage?: string // defaults to 'Cancel?'
}
): Observable<boolean>
Display confirmation dialog. The dialog will close when user clicks on either the accept or cancel button.
Returns true if user clicks on the acceptButton
and false if user clicks on cancelButton
.
withProgress<T = any> (
work: Observable<T>
title?: string // defaults to 'Please Wait...'
): Observable<T | undefined>
Display dialog with a spinner/progress bar that blocks UI interaction until processing of associated observable workload completes.
Returns the last value emitted by the workload. If workload throws error, progress dialog will close and return undefined.
withForm (
title: string,
fields: QuickFormField[],
options?: {
content?: string
submitButton?: string
cancelButton?: string
}
): Observable<any>
DialogService class exposes functions to create alert, confirmation, progress and form based dialogs.
The dialog will close and return form values (as a JSON object) when user clicks on submit button (provided all field validation passed).If user cancels the form, the dialog will close and return false. For documentation on QuickFormField, refer to ng-quick-form.
Reach out to me on Twitter at @kctang
MIT
[0.1.1] - 2019-05-19
FAQs
Reactive Angular modal dialogs. Create alert, confirmation, progress and form based dialogs without writing component templates.
The npm package dialog-service receives a total of 1 weekly downloads. As such, dialog-service popularity was classified as not popular.
We found that dialog-service 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.
Security News
require(esm) backported to Node.js 20, easing the transition to ESM-only packages and reducing complexity for developers as Node 18 nears end-of-life.
Security News
PyPI now supports iOS and Android wheels, making it easier for Python developers to distribute mobile packages.
Security News
Create React App is officially deprecated due to React 19 issues and lack of maintenance—developers should switch to Vite or other modern alternatives.