Created
November 20, 2019 13:30
-
-
Save Ze1598/a6fe9899dbe3e5c2b7b7f2c87bb746cf to your computer and use it in GitHub Desktop.
Modal component: app.component.ts
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 './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