MatDialog Error: No provider for InjectionToken mat-dialog-scroll-strategy

时间:2017-10-12 09:51:33

标签: angular-material2

at including Provider: MatDialog in the Constructur

      constructor(groupService: GroupService, public dialog: MatDialog) 

I get following error at runtime

     Error: No provider for InjectionToken mat-dialog-scroll-strategy!

I have included the Matdialog in the "app.module.ts" Do i need a different Provider for it and which one? I use angular-material 2.0.0b12

thanks

2 个答案:

答案 0 :(得分:13)

您需要在导入中包含MatDialog模块。

import {MatDialogModule} from '@angular/material';
@NgModule({
   imports :[MatDialogModule],
   ...
})

答案 1 :(得分:1)

从“ @ angular / material / dialog”导入{MatDialogModule}导入对话框; 通过将以下代码添加到module.ts文件中

import {MatDialogModule} from '@angular/material/dialog';

然后将其导入到导入中,如下所示,

const MaterialComponent = [MatDialogModule];