gpt4 book ai didi

angular - 没有 MdDialogRef 的提供者

转载 作者:行者123 更新时间:2023-12-02 14:58:03 24 4
gpt4 key购买 nike

我重新讨论了这个问题,因为它在类似的讨论中没有解决我的问题。

即使我一步步按照官方教程操作,我仍然遇到错误“没有 MdDialogRef 提供程序”。

我有两个组件。第一个组件:

import { MdDialog} from "@angular/material";

import { DocumentDialogComponent } from './document-dialog.component';

@Component({
selector: 'documents-list',
template
})
export class DocumentsListComponent {

constructor(
public dialog: MdDialog) {
}

openFormDialog() {

let dialogRef = this.dialog.open(DocumentDialogComponent,
{
}
);
dialogRef.afterClosed().subscribe(result => {
this.selectedOption = result;
});
}

我的第二个组件(对话框):

import { MdDialogRef} from "@angular/material";

@Component({
selector: 'document-dialog',
template
})

export class DocumentDialogComponent {
constructor(
public dialogRef: MdDialogRef<DocumentDialogComponent>
) {}
}

还有我的模块配置:

  import { MaterialModule } from "@angular/material";
import { DocumentsListComponent } from './documents-list.component';
import { DocumentDialogComponent } from './document-dialog.component';

imports : [
MaterialModule.forRoot()
],

declarations: [
AppComponent,
DocumentListComponent,
DocumentDialogComponent
],
entryComponents: [
AppComponent,
DocumentListComponent,
DocumentDialogComponent
],
providers: [
],
bootstrap: [
AppComponent
]

为什么我仍然有错误:

Error in ./DocumentsListComponent class DocumentsListComponent - inline template:0:167 caused by: No provider for MdDialogRef!

最佳答案

我删除了<DocumentsListComponent></DocumentsListComponent>在我的模板中添加标签,现在它可以工作了。

关于angular - 没有 MdDialogRef 的提供者,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42492091/

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