src/app/core/modal/modal.component.ts
selector | app-modal |
templateUrl | ./modal.component.html |
Properties |
Methods |
constructor(dialogRef: MatDialogRef
|
|||||||||
Defined in src/app/core/modal/modal.component.ts:10
|
|||||||||
Parameters :
|
cancel |
cancel()
|
Defined in src/app/core/modal/modal.component.ts:25
|
Returns :
void
|
ngOnInit |
ngOnInit()
|
Defined in src/app/core/modal/modal.component.ts:19
|
Returns :
void
|
ok |
ok()
|
Defined in src/app/core/modal/modal.component.ts:21
|
Returns :
void
|
message |
Type : string
|
Defined in src/app/core/modal/modal.component.ts:9
|
title |
Type : string
|
Defined in src/app/core/modal/modal.component.ts:10
|
import { Component, Inject, OnInit } from '@angular/core';
import { MatDialogRef, MAT_DIALOG_DATA } from '@angular/material/dialog';
@Component({
selector: 'app-modal',
templateUrl: './modal.component.html'
})
export class ModalComponent implements OnInit {
message: string;
title: string;
constructor(
private dialogRef: MatDialogRef<ModalComponent>,
@Inject(MAT_DIALOG_DATA) data
) {
this.title = data.title;
this.message = data.message;
}
ngOnInit() {}
ok() {
this.dialogRef.close(true);
}
cancel() {
this.dialogRef.close(false);
}
}
<h2 mat-dialog-title>{{title}}</h2>
<mat-dialog-content>
<p>{{message}}</p>
</mat-dialog-content>
<mat-dialog-actions>
<button class="mat-raised-button" (click)="cancel()">Cancel</button>
<button class="mat-raised-button mat-primary" (click)="ok()">OK</button>
</mat-dialog-actions>