当我尝试遵循https://material.angular.io/components/dialog/overview 中的对话教程时发生了这种情况, 并且我收到了上面的错误,所以如果有人知道我应该怎么做来解决这个问题?
这是我的代码:模态的 html
<h1 mat-dialog-title>Warning</h1>
<div mat-dialog-content>
<p>Are you sure you want to delete the book {{data.title}} ?</p>
</div>
<div mat-dialog-actions>
<button mat-button [mat-dialog-close]="data.title" tabindex="2">Ok</button>
<button mat-button (click)="onNoClick()" tabindex="-1">No Thanks</button>
</div>
Run Code Online (Sandbox Code Playgroud)
激活模态的类:
import { Component, OnInit, Inject } from '@angular/core';
import { MatDialogRef, MAT_DIALOG_DATA} from '@angular/material';
@Component({
selector: 'app-remove-book',
templateUrl: './remove-book.component.html',
styleUrls: ['./remove-book.component.scss']
})
export class RemoveBookComponent implements OnInit {
constructor(
public dialogRef: MatDialogRef<RemoveBookComponent>,
@Inject(MAT_DIALOG_DATA) public data: any) { }
onNoClick(): void {
this.dialogRef.close();
}
ngOnInit() …
Run Code Online (Sandbox Code Playgroud) angular ×1