• Skip to main content
  • Skip to primary sidebar

Web Development Archive

  • Archive
You are here: Home / Other / Confirmation Service

Confirmation Service

import { Injectable } from '@angular/core';
import { Observable, Subject } from 'rxjs';

import { Confirmation } from '../models';

@Injectable({
providedIn: 'root',
})
export class ConfirmationService {
private readonly requireConfirmation$ = new Subject<Confirmation | null>();
public requireConfirmationObs$: Observable<Confirmation | null>;
private readonly acceptConfirmation$ = new Subject<Confirmation | null>();
public acceptObs$: Observable<Confirmation | null>;

constructor() {
this.requireConfirmationObs$ = this.requireConfirmation$.asObservable();
this.acceptObs$ = this.acceptConfirmation$.asObservable();
}

confirm(confirmation: Confirmation): this {
this.requireConfirmation$.next(confirmation);
return this;
}

close(): this {
this.requireConfirmation$.next(null);
return this;
}

onAccept(): void {
this.acceptConfirmation$.next(null);
}
}
onDeleteProfileClick(event: Event): void {
event.preventDefault();

this.confirmationService.confirm({
header: this.translocoService.translate('PROFILE.DELETE_PROFILE'),
message: this.translocoService.translate('PROFILE.DELETE_PROFILE_CONFIRMATION'),
acceptLabel: this.translocoService.translate('PROFILE.DELETE_PROFILE'),
rejectLabel: this.translocoService.translate('SHARED.CANCEL'),
icon: 'icon-alert-triangle',
accept: () => {
console.log('ITT HÍVJUK AZ APIT A TÖRLÉSHEZ');
},
});
}

Filed Under: Other

About Gabor Flamich

I'm a web developer and designer based in Budapest, Hungary. In recent years, I've documented hundreds of solutions I came across during development. This site is an archive for useful code snippets on WordPress, Genesis Framework and WooCommerce. If You have any questions related to WordPress development, get in touch!

Primary Sidebar

  • angular.io
© 2026 WP Flames - All Right Reserved