【发布时间】:2018-03-08 01:49:22
【问题描述】:
我正在尝试使用角度材质对话框组件。我过去用过它,我没有问题。但不知何故,我不能像过去那样使用它。这是我的实现:
export class FilterDialogComponent implements OnInit {
public clientDepartementFilter: string;
public partnerDepartmentFilter: string;
public checkboxFilters: CheckboxFilters;
constructor(public dialogRef: MatDialogRef<FilterDialogComponent>,
@Inject(MAT_DIALOG_DATA) public data: any) {
this.checkboxFilters = data.checkboxFilters;
this.clientDepartementFilter = data.clientDepartementFilter;
this.partnerDepartmentFilter = data.partnerDepartmentFilter;
}
closeDialog(): void {
this.dialogRef.close({ data: this.clientDepartementFilter });
}
我这样打开它:
public openDialog(): void {
this.dialog.open(FilterDialogComponent, {
data: {
checkboxFilters: this.checkboxFilters,
clientDepartementFilter: this.clientDepartementFilter,
partnerDepartmentFilter: this.partnerDepartmentFilter
}
}).afterClosed().subscribe(result => {
console.log(result);
});
}
我的代码可以编译,但是当我使用
创建当前对话框的引用时出现错误public dialogRef: MatDialogRef<FilterDialogComponent>
错误如下:
TS2314:通用类型“MatDialogRef”需要 3 个类型参数
当我在 MatDialog 中添加任何类型时,错误消失但我无法再编译我的代码...
现在我有以下错误:
错误 TS2707:通用类型“MatDialogRef”需要 1 到 2 个类型参数。
我尝试更新角度材料 angularCli 和 typescript,但它仍然无法编译。
"@angular/cli": "^1.7.2",
"@angular/compiler-cli": "^5.0.0",
“打字稿”:“^2.4.2”
"@angular/material": "^5.2.4",
关于它为什么会发生的任何建议或想法? 感谢您的帮助!
【问题讨论】:
标签: angular typescript angular-material2