Created
December 28, 2019 14:40
-
-
Save Ze1598/fa4e3ec1ee7928fad0756f5894077d0d to your computer and use it in GitHub Desktop.
Reusable modal component: app.component.ts (first version)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Component } from '@angular/core'; | |
import { MatDialog, MatDialogConfig } from '@angular/material/dialog'; | |
import { ModalComponent } from './components/modal/modal.component'; | |
@Component({ | |
selector: 'app-root', | |
templateUrl: './app.component.html', | |
styleUrls: ['./app.component.css'] | |
}) | |
export class AppComponent { | |
constructor(public matDialog: MatDialog) { } | |
openModal() { | |
const dialogConfig = new MatDialogConfig(); | |
// The user can't close the dialog by clicking outside its body | |
dialogConfig.disableClose = true; | |
dialogConfig.id = "modal-component"; | |
dialogConfig.height = "350px"; | |
dialogConfig.width = "600px"; | |
// https://material.angular.io/components/dialog/overview | |
const modalDialog = this.matDialog.open(ModalComponent, dialogConfig); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment