gpt4 book ai didi

Angular 4/5 未捕获错误 : Template parse errors: Can't bind to 'mat-dialog-close' since it isn't a known property of 'button'

转载 作者:行者123 更新时间:2023-12-04 13:34:46 32 4
gpt4 key购买 nike

当我尝试按照对话教程进行操作时发生了这种情况
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/

32 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com