我想從Angular 2的材質模塊中使用MdDialog。我有一個組件,我試圖在下面顯示的對話框中使用。沒有提供MdDialog錯誤
import { Component, OnInit } from '@angular/core';
import { Aircraft } from '../shared/aircraft';
import { AircraftService } from '../shared/aircraft.service';
import { MdDialog, MdDialogRef } from '@angular/material';
import { NewAircraftDialogComponent } from '../new-aircraft-dialog/new-aircraft-dialog.component';
@Component({
selector: 'app-statusboard',
templateUrl: './statusboard.component.html',
styleUrls: ['./statusboard.component.css']
})
export class StatusboardComponent implements OnInit {
aircrafts: Aircraft[] = [];
constructor(private aircraftService: AircraftService,
public dialog: MdDialog) { }
ngOnInit(): void {
this.aircraftService.getAircrafts()
.then(aircrafts => this.aircrafts = aircrafts);
}
openNewAircraftDialog(): void {
let dialogRef = this.dialog.open(NewAircraftDialogComponent, {
width: '300px'
});
dialogRef.afterClosed().subscribe(result => {
console.log('The dialog was closed');
});
}
}
而對話框組件如下所示。
但我得到一個錯誤控制檯說:「錯誤:未捕獲的(在承諾):錯誤:不!提供商MdDialog」
環顧網上,它說要添加「entryComponents:[NewAircraftDialogComponent]」NgModule。我有,但那並沒有解決這個問題。