Run the CLI
Use the CLI to add the component to your project.
npx @ngzard/ui@latest add alert-dialogA modal dialog that interrupts the user with important content and expects a response.
import { Component, inject } from '@angular/core';
import { ZardButtonComponent } from '../../button/button.component';
import { ZardAlertDialogService } from '../alert-dialog.service';
@Component({
selector: 'zard-demo-alert-dialog-default',
imports: [ZardButtonComponent],
standalone: true,
template: `
<button z-button zType="outline" (click)="showDialog()">Show Dialog</button>
`,
})
export class ZardDemoAlertDialogDefaultComponent {
private alertDialogService = inject(ZardAlertDialogService);
showDialog() {
this.alertDialogService.confirm({
zTitle: 'Are you absolutely sure?',
zDescription:
'This action cannot be undone. This will permanently delete your account and remove your data from our servers.',
zOkText: 'Continue',
zCancelText: 'Cancel',
});
}
}
Use the CLI to add the component to your project.
npx @ngzard/ui@latest add alert-dialogpnpm dlx @ngzard/ui@latest add alert-dialogyarn dlx @ngzard/ui@latest add alert-dialogbunx @ngzard/ui@latest add alert-dialogCreate the component directory structure and add the following files to your project.
import { Component, inject } from '@angular/core';
import { ZardButtonComponent } from '../../button/button.component';
import { ZardAlertDialogService } from '../alert-dialog.service';
@Component({
selector: 'zard-demo-alert-dialog-default',
imports: [ZardButtonComponent],
standalone: true,
template: `
<button z-button zType="outline" (click)="showDialog()">Show Dialog</button>
`,
})
export class ZardDemoAlertDialogDefaultComponent {
private alertDialogService = inject(ZardAlertDialogService);
showDialog() {
this.alertDialogService.confirm({
zTitle: 'Are you absolutely sure?',
zDescription:
'This action cannot be undone. This will permanently delete your account and remove your data from our servers.',
zOkText: 'Continue',
zCancelText: 'Cancel',
});
}
}