update messagesdemo

This commit is contained in:
Mehmet Çetin
2025-01-08 12:02:11 +03:00
parent 90ec3f9976
commit fa2e167e3f

View File

@@ -21,6 +21,7 @@ import { FormsModule } from '@angular/forms';
<p-button (click)="showInfoViaToast()" label="Info" severity="info" /> <p-button (click)="showInfoViaToast()" label="Info" severity="info" />
<p-button (click)="showWarnViaToast()" label="Warn" severity="warn" /> <p-button (click)="showWarnViaToast()" label="Warn" severity="warn" />
<p-button (click)="showErrorViaToast()" label="Error" severity="danger" /> <p-button (click)="showErrorViaToast()" label="Error" severity="danger" />
<p-toast />
</div> </div>
<div class="font-semibold text-xl mt-4 mb-4">Inline</div> <div class="font-semibold text-xl mt-4 mb-4">Inline</div>
@@ -61,38 +62,18 @@ export class MessagesDemo {
constructor(private service: MessageService) {} constructor(private service: MessageService) {}
showInfoViaToast() { showInfoViaToast() {
this.service.add({ key: 'tst', severity: 'info', summary: 'Info Message', detail: 'PrimeNG rocks' }); this.service.add({ severity: 'info', summary: 'Info Message', detail: 'PrimeNG rocks' });
} }
showWarnViaToast() { showWarnViaToast() {
this.service.add({ key: 'tst', severity: 'warn', summary: 'Warn Message', detail: 'There are unsaved changes' }); this.service.add({ severity: 'warn', summary: 'Warn Message', detail: 'There are unsaved changes' });
} }
showErrorViaToast() { showErrorViaToast() {
this.service.add({ key: 'tst', severity: 'error', summary: 'Error Message', detail: 'Validation failed' }); this.service.add({ severity: 'error', summary: 'Error Message', detail: 'Validation failed' });
} }
showSuccessViaToast() { showSuccessViaToast() {
this.service.add({ key: 'tst', severity: 'success', summary: 'Success Message', detail: 'Message sent' }); this.service.add({ severity: 'success', summary: 'Success Message', detail: 'Message sent' });
}
showInfoViaMessages() {
this.msgs = [];
this.msgs.push({ severity: 'info', summary: 'Info Message', detail: 'PrimeNG rocks' });
}
showWarnViaMessages() {
this.msgs = [];
this.msgs.push({ severity: 'warn', summary: 'Warn Message', detail: 'There are unsaved changes' });
}
showErrorViaMessages() {
this.msgs = [];
this.msgs.push({ severity: 'error', summary: 'Error Message', detail: 'Validation failed' });
}
showSuccessViaMessages() {
this.msgs = [];
this.msgs.push({ severity: 'success', summary: 'Success Message', detail: 'Message sent' });
} }
} }