Home > front end >  'MAT_DIALOG_DATA' was not found in '@angular/material'
'MAT_DIALOG_DATA' was not found in '@angular/material'

Time:11-13

My project was building ok at one time, but after trying to fix a problem it is no longer building. I might have upgraded, downgraded, deleted node_modules folder, deleted dist folder... I don't remember. Now when I do ng build I'm getting

./src/app/my.component.ts:148:188-203 - Error: export 'MAT_DIALOG_DATA' (imported as 'MAT_DIALOG_DATA') was not found in '@angular/material' (possible exports: ɵɵtsModuleIndicatorApiExtractorWorkaround).

Inside my.component.ts there is a

import { MatDialogRef, MAT_DIALOG_DATA } from '@angular/material';

constructor( private myService: MyService,
             @Inject(MAT_DIALOG_DATA) public data: any) {

It would seem 'MAT_DIALOG_DATA' is not available in the version of @angular/material that I’m using.

Here is my angular version info:

Angular CLI: 12.2.13
Node: 14.17.0
Package Manager: npm 6.14.13
OS: win32 x64

Angular: 12.2.13
... animations, cli, common, compiler, compiler-cli, core, forms
... language-service, localize, router

Package                             Version
-------------------------------------------------------------
@angular-devkit/architect           0.1202.13
@angular-devkit/build-angular       12.2.13
@angular-devkit/core                12.2.13
@angular-devkit/schematics          12.2.13
@angular/cdk                        12.2.2
@angular/material                   12.2.2
@angular/material-moment-adapter    12.2.2
@angular/platform-browser           12.2.2
@angular/platform-browser-dynamic   12.2.2
@schematics/angular                 12.2.13 (cli-only)
ng-packagr                          12.2.5
rxjs                                6.6.7
typescript                          4.3.5

Any suggestions?

CodePudding user response:

you should inject it from @angular/material/dialog

import {MatDialog, MAT_DIALOG_DATA} from '@angular/material/dialog';

check the examples

https://material.angular.io/components/dialog/overview

  • Related