Skip to content

Instantly share code, notes, and snippets.

@Ze1598
Created November 22, 2019 17:04
Show Gist options
  • Save Ze1598/281f6cd57e36074bb4d73045b9c147af to your computer and use it in GitHub Desktop.
Save Ze1598/281f6cd57e36074bb4d73045b9c147af to your computer and use it in GitHub Desktop.
Modal component: modal.component.ts
import { Component, OnInit } from '@angular/core';
import { MatDialogRef } from '@angular/material/dialog';
@Component({
selector: 'app-modal',
templateUrl: './modal.component.html',
styleUrls: ['./modal.component.css']
})
export class ModalComponent implements OnInit {
constructor(public dialogRef: MatDialogRef<ModalComponent>) { }
ngOnInit() {
}
// When the user clicks the action button a.k.a. the logout button in the\
// modal, show an alert and followed by the closing of the modal
actionFunction() {
alert("You have logged out.");
this.closeModal();
}
// If the user clicks the cancel button a.k.a. the go back button, then\
// just close the modal
closeModal() {
this.dialogRef.close();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment