-1

I unfortunately made the dumb decision of updating my Angular project to the newest version. I knew going in that it would be hell and it is going that way.

I am getting this error below in my console that i've never run across before.. The app is compiling successfully but browser is not displaying anything and getting this error.

I will try to show all relevant info that I can. I am not seeing this error anywhere unfortunately

any help would be appreciated.

Uncaught Error: Type MatDialogRef does not have 'ɵmod' property.
at getNgModuleDef (core.js:1022)
at recurse (core.js:24966)
at recurse (core.js:24977)
at registerNgModuleType (core.js:24962)
at new NgModuleFactory$1 (core.js:25076)
at compileNgModuleFactory__POST_R3__ (core.js:28679)
at PlatformRef.bootstrapModule (core.js:28922)
at Module.zUnb (main.ts:11)
at __webpack_require__ (bootstrap:79)
at Object.0 (main.js:475)

package.json

"dependencies": {
"@angular-devkit/core": "^11.2.2",
"@angular/animations": "11.0.5",
"@angular/cdk": "^11.2.2",
"@angular/common": "11.0.5",
"@angular/compiler": "11.0.5",
"@angular/core": "11.0.5",
"@angular/forms": "11.0.5",
"@angular/http": "^7.2.16",
"@angular/material": "^11.2.2",
"@angular/material-moment-adapter": "^11.2.2",
"@angular/platform-browser": "11.0.5",
"@angular/platform-browser-dynamic": "^11.0.5",
"@angular/router": "^8.0.0",
"angular-bootstrap-datetimepicker": "^1.1.4",
"angular-eonasdan-datetimepicker": "^0.3.9",
"angular-material": "^1.2.2",
"angular-moment-picker": "^0.10.1",
"angular-ui-bootstrap-datetimepicker": "^2.5.0",
"boostrap": "^2.0.0",
"bootstrap": "^3.4.1",
"chart.js": "^2.9.4",
"core-js": "^2.6.12",
"font-awesome": "^4.7.0",
"fullcalendar": "^3.10.2",
"hammerjs": "^2.0.8",
"html2canvas": "^1.0.0-rc.7",
"jquery": "^3.5.1",
"jspdf": "^1.5.3",
"moment": "^2.29.1",
"ng2-eonasdan-datetimepicker": "^0.1.4",
"ng2-file-upload": "^1.4.0",
"ngx-bootstrap": "^1.8.1",
"ngx-quill-editor": "^2.2.1",
"node-sass": "^4.14.1",
"primeicons": "^1.0.0",
"primeng": "^8.1.1",
"primeng-lts": "^9.2.3",
"quill": "^1.3.7",
"rxjs": "6.4.0",
"rxjs-compat": "^6.6.6",
"sweetalert": "^2.1.2",
"textangular": "^1.5.16",
"tslib": "^1.14.1",
"web-animations-js": "^2.3.2",
"xlsx": "^0.16.9",
"zone.js": "^0.10.2"
 },


"devDependencies": {
"@angular-devkit/build-angular": "^0.1102.2",
"@angular/cli": "^11.2.2",
"@angular/compiler-cli": "11.0.5",
"@angular/language-service": "^5.2.11",
"@types/jasmine": "~2.5.53",
"@types/node": "^6.14.13",
"codelyzer": "^4.5.0",
"jasmine-core": "~2.6.2",
"jasmine-spec-reporter": "~4.1.0",
"karma": "~1.7.0",
"karma-chrome-launcher": "~2.1.1",
"karma-cli": "~1.0.1",
"karma-coverage-istanbul-reporter": "^1.4.3",
"karma-jasmine": "^1.1.2",
"karma-jasmine-html-reporter": "^0.2.2",
"protractor": "~5.1.2",
"ts-node": "~3.2.0",
"tslint": "~5.7.0",
"typescript": "^4.0.7"
}

app.module.ts

import {MatDialogModule, MatDialogRef} from '@angular/material/dialog';
imports: [
      MatDialogRef],
 providers: [LocationService,
{provide: LocationStrategy, useClass: HashLocationStrategy},
{ provide: MatDialogRef, useValue: {} }]

implementation

import {MatDialogRef} from '@angular/material/dialog';
export class DialogComponent implements AfterViewInit{}
constructor(public dialogRef: MatDialogRef<DialogComponent>

 this.dialogRef.afterClosed().subscribe((sendNow) => {...}
Rob DePietro
  • 284
  • 2
  • 8
  • 23
  • 1
    `imports: [MatDialogRef],` modules should be used in imports section, and here, you are using ref. change it to MatDialogModule and the error will be gone. also remove this provider `provide: MatDialogRef, useValue: {}` – Andrei Mar 01 '21 at 18:34
  • @Andrei I tried that as well and just now again and I'm getting the above error message at the top of the problem that I just edited with the 'component AppComponent is not part of any NgModule or the module has not been imported into your module.' – Rob DePietro Mar 01 '21 at 18:41
  • My AppComponent error I mentioned was due to the me bootstrappng the 'appComponent' inside my routing module. Onced removed it works but still issues with MatDialogRef – Rob DePietro Mar 01 '21 at 19:08
  • Duplicate? https://stackoverflow.com/questions/46686310/no-provider-for-matdialogref – SehaxX Mar 01 '21 at 19:15
  • I faced a similar issue with an Angular package I was publishing that imported the Material library. It turned out the issue was with Ivy compilation, and solved it by running "ngcc" so that the dependencies (such as @angular/material) had proper __ivy_ngcc__ subfolders inside of node_modules. These ended up defining the ɵmod missing properties for the imported @angular/material modules. – Chris Mar 08 '21 at 22:28

1 Answers1

-1

Add MatDialogModule into imports but not MatDialogRef in module.ts