help(MatDialogue): MatDialog box is not appearing after upgrading to anuglar 9
What are you trying to do?
Trying to open material dialogue box but it is not visible, only the layover background comes up. In angular 7 it was working with no problem but after upgrading to angular 9 it has started giving me this error in the browser console:
ERROR TypeError: Cannot read property 'hasAttached' of undefined
at MatDialogContainer.attachComponentPortal (dialog.js:187)
at MatDialog._attachDialogContent (dialog.js:796)
at MatDialog.open (dialog.js:674)
at CreateStrategyComponent.openDialog_enL_lhs (create-strategy.component.ts:200)
at CreateStrategyComponent_div_73_div_23_div_3_select_7_Template_select_click_0_listener (template.html:137)
at executeListenerWithErrorHandling (core.js:21819)
at wrapListenerIn_markDirtyAndPreventDefault (core.js:21861)
at HTMLSelectElement.<anonymous> (platform-browser.js:976)
at ZoneDelegate.invokeTask (zone-evergreen.js:399)
at Object.onInvokeTask (core.js:41645)
What troubleshooting steps have you tried?
I have tried updating the angular material to 9.1 version
Environment
- Angular:9
- CDK/Material: @angular/cdk=9.1.3, @angular/material 7.3.7
- Browser(s):Chrome
- Operating System (e.g. Windows, macOS, Ubuntu): Ubuntu
package.json file
{ "name": "myproj", "version": "0.0.0", "scripts": { "ng": "ng", "start": "ng serve", "build": "ng build", "test": "ng test", "lint": "ng lint", "e2e": "ng e2e" }, "private": true, "dependencies": { "@angular/animations": "^9.0.0", "@angular/cdk": "^9.1.3", "@angular/common": "^9.0.0", "@angular/compiler": "^9.0.0", "@angular/core": "^9.0.0", "@angular/forms": "^9.0.0", "@angular/material": "^7.3.7", "@angular/platform-browser": "^9.0.0", "@angular/platform-browser-dynamic": "^9.0.0", "@angular/platform-server": "^9.0.0", "@angular/router": "^9.0.0", "@r3droger/windowref": "0.0.1", "@types/selectize": "^0.12.34", "angular-bootstrap-md": "^7.5.3", "angular-google-charts": "^1.1.4", "angular-plotly.js": "^2.0.0", "angularx-social-login": "^2.2.1", "bulma": "^0.8.0", "chart.js": "^2.9.2", "core-js": "^3.6.5", "font-awesome": "^4.7.0", "hammerjs": "^2.0.8", "highcharts": "^8.1.2", "highcharts-angular": "^2.4.0", "lightweight-charts": "^3.1.2", "ng-selectize": "^1.1.3", "ng2-charts": "^2.3.0", "ng2-search-filter": "^0.5.1", "plotly.js": "^1.54.6", "rxjs": "^6.6.0", "rxjs-compat": "^6.0.0", "sweetalert2": "^8.13.0", "tslib": "^1.9.0", "window": "^4.2.6", "zone.js": "^0.10.3" }, "devDependencies": { "@angular-builders/custom-webpack": "^9.2.0", "@angular-devkit/build-angular": "^0.900.1", "@angular/cli": "^9.0.0", "@angular/compiler-cli": "^9.0.0", "@angular/language-service": "^9.0.0", "@types/jasmine": "^3.5.11", "@types/jasminewd2": "~2.0.3", "@types/jquery": "^3.3.31", "@types/node": "^14.0.23", "brotli-webpack-plugin": "^1.1.0", "codelyzer": "^6.0.0", "compression-webpack-plugin": "^4.0.0", "jasmine-core": "^3.5.0", "jasmine-spec-reporter": "^5.0.2", "karma": "^5.1.0", "karma-chrome-launcher": "^3.1.0", "karma-cli": "^2.0.0", "karma-coverage-istanbul-reporter": "~2.0.1", "karma-jasmine": "^3.3.1", "karma-jasmine-html-reporter": "^1.5.4", "protractor": "^7.0.0", "rxjs-tslint": "^0.1.8", "ts-node": "~7.0.0", "tslint": "^6.1.2", "typescript": "^3.8.3" } }
Same issue here on Angular 10, however it works okay when serving the application with ng serve. If I build the application for production with ivy (which is by default enabled), the same error is thrown. Might be related to: https://github.com/angular/components/issues/15605
In my case even with normal ng serve the issue still occurs.
It looks like the versions of @angular/cdk and @angular/material don't match up. Have you tried to update @angular/material to version 9?
i matched them and installed version 9 of both and stumbled upon this error.
Uncaught TypeError: Cannot read property 'ngModule' of undefined
at isModuleWithProviders (core.js:39750)
at expandModuleWithProviders (core.js:39740)
at Array.map (<anonymous>)
at Function.get (core.js:39216)
at getNgModuleDef (core.js:2210)
at assertNgModuleType (core.js:2950)
at compileNgModuleFactory__POST_R3__ (core.js:42288)
at PlatformRef.bootstrapModule (core.js:42676)
at Module../src/main.ts (main.ts:12)
at __webpack_require__ (bootstrap:84)
I also matched both of them in this version(7.3.7) . 7.3.7 was working all fine in my anuglar 7 version. No luck
ok i solved the issue. I followed an article to upgrade my angular 7 to angular 9 article....in one step it asked me to change few key values in file tsconfig.json
compilerOptions:
The module value to esnext
The target value to es2015
so because of that i had issue with material. When i changed it back to what it was before i.e:
module value to commonjs
target value to es5
it worked. Not sure if this is the correct way to do it. Let me know if there is any better solution
This issue has been automatically locked due to inactivity. Please file a new issue if you are encountering a similar or related problem.
Read more about our automatic conversation locking policy.
This action has been performed automatically by a bot.