비슷한 글에서 내 문제가 해결되지 않았으므로이 문제가 다시 발생했습니다.MdDialogRef에 대한 내용이 없습니다.
공식 자습서를 단계별로 수행 한 후에도 '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>
) {}
}
그리고 내 모듈 설정 :
Error in ./DocumentsListComponent class DocumentsListComponent - inline template:0:167 caused by: No provider for MdDialogRef!
: 난 여전히 오류가 왜
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
]
당신이'MaterialModule'을 가져 여기
는 수정 작업 코드는? –가져 오기 섹션. 내 질문을 업데이트했습니다 – Kivo
'MaterialModule.forRoot()'대신'MaterialModule'을 가져 오 려 했습니까? – gsc