• Skip to main content
  • Skip to primary sidebar

Web Development Archive

  • Archive
You are here: Home / Angular / Modal / Dialog

Modal / Dialog

<button (click)="onClickOrderDialog($event)" />
public onClickOrderDialog(event: Event): void {
event.preventDefault();
const dialogRef = this._dialogService.open(DialogComponent);
dialogRef.afterClosed$().subscribe(() => {});
this._cdr.markForCheck();
}
export class OrderingDialogComponent implements OnInit, OnDestroy {
private readonly _deviceService = inject(DeviceService);
private readonly _cdr = inject(ChangeDetectorRef);
private readonly _destroy$ = new Subject<void>();
public isMobile: boolean = false;
public data: string;
public FieldType = FieldType;

public constructor(
@Inject(DIALOG_DATA) dialogData: string,
private readonly _dialogRef: DialogRef<unknown>
) {
this.data = dialogData;
}

public ngOnInit(): void {
this._deviceService.isMobileObs$.pipe(takeUntil(this._destroy$)).subscribe((isMobile) => {
this.isMobile = isMobile;
this._cdr.markForCheck();
});
}

public ngOnDestroy(): void {
this._destroy$.next();
this._destroy$.complete();
}

public onClose(): void {
if (this._dialogRef) {
this._dialogRef.close(null);
}
}
}

Filed Under: Angular

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