mseemann/angular2-mdl

View on GitHub
projects/core/src/lib/dialog/mdl-alert.component.ts

Summary

Maintainability
A
0 mins
Test Coverage
A
100%
import {
  Component,
  EventEmitter,
  HostBinding,
  Input,
  Output,
} from "@angular/core";
import { MdlDialogService } from "./mdl-dialog.service";

@Component({
  selector: "mdl-alert",
  template: ``,
  exportAs: "mdlAlert",
})
export class MdlAlertComponent {
  @Input()
  title: string | undefined;

  @Input()
  message = "";

  @Input()
  okText: string | undefined;

  @HostBinding("style.display")
  display = "none";

  @Output()
  confirmed = new EventEmitter();

  constructor(private mdlDialogService: MdlDialogService) {}

  show(): void {
    this.mdlDialogService
      .alert(this.message, this.okText, this.title)
      .subscribe(() => {
        this.confirmed.emit();
      });
  }
}