作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
当我尝试按照对话教程进行操作时发生了这种情况
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>
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() {
}
}
and the method in the class that supposes to active the modal:
removeContact(i){
let dialogRef = this.dialog.open(RemoveBookComponent, {
width: '250px',
data: { ok: this.ok, title: this.contactsArr[i].title }
});
dialogRef.afterClosed().subscribe(result => {
console.log('The dialog was closed');
this.contactsArr.splice(i,1);
});
}
最佳答案
好吧,在我在 git 上询问之后,我发现了我的问题,它是:
导入 -> MatDialogModule
我希望它会对某人有所帮助,即使只是给出了错误的想法
在以下位置查看:
https://github.com/angular/material2/issues/8911
关于Angular 4/5 未捕获错误 : Template parse errors: Can't bind to 'mat-dialog-close' since it isn't a known property of 'button' ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47707167/
我是一名优秀的程序员,十分优秀!