After I upgraded my project to version 15 of Angular, following the official Angular documentation, I encountered an issue with my MatDialog not opening correctly. The problem seemed to stem from removing the entryComponents and transforming all components to standalone. Everything functions correctly up to the Dialog components.
In the console, I kept getting the error message "Cannot read properties of undefined (reading 'errorState'). Even recreating the MatDialog component from scratch did not resolve this error. I am perplexed as to where this issue could be originating from. Can anyone provide insight on how to troubleshoot this?
TS Button to open Dialog:
openAddPhonenumberDialog() {
const dialogRef = this.dialog.open(AddPhonenumberComponent, {
minWidth: "300px",
autoFocus: false,
});
}
TS PhonenumberComponnet
Component({
selector: "app-add-phonenumber",
templateUrl: "./add-phonenumber.component.html",
styleUrls: ["./add-phonenumber.component.css"],
standalone: true,
imports: [
MatDialogModule,
FormsModule,
ReactiveFormsModule,
MatFormFieldModule,
MatInputModule,
MatSelectModule,
MatOptionModule,
NgIf,
MatButtonModule,
],
})
HTML PhonenumberComponent
<h2 mat-dialog-title>Add a new phonenumber</h2>
<form [formGroup]="addPhonenumberForm" (ngSubmit)="onAddNewPhonenumber()">
<mat-dialog-content style="display:flex;flex-direction: column;">
<mat-form-field>
<mat-label>Phonenumber</mat-label>
<input matInput formControlName="phonenumber" type="tel" required
(input)="formatInput()">
</mat-form-field>
</mat-dialog-content>
<mat-dialog-actions>
<button mat-button [mat-dialog-close] (click)="close()">Close</button>
<button type="submit" mat-button [mat-dialog-close]="result" >Save</button>
</mat-dialog-actions>
</form>
My package.json:
"@angular-devkit/core": "^16.1.8",
"@angular-devkit/schematics": "^16.1.8",
"@angular/animations": "~15.2.9",
"@angular/cdk": "^15.2.9",
"@angular/common": "~15.2.9",
"@angular/compiler": "~15.2.9",
"@angular/core": "~15.2.9",
"@angular/forms": "~15.2.9",
"@angular/material": "^15.2.9",
"@angular/platform-browser": "^15.2.9",
"@angular/platform-browser-dynamic": "~15.2.9",
"@angular/router": "~15.2.9",
"@types/gapi.client.drive": "^3.0.8",
"angular-in-memory-web-api": "^0.9.0",
"bootstrap": "^4.4.1",
"core-js": "^2.5.4",
"hammerjs": "^2.0.8",
"jquery": "^3.6.0",
"moment": "^2.26.0",
"popper.js": "^1.16.0",
"rxjs": "^6.5.5",
"tslib": "^2.0.0",
"xstate": "~4.6.7",
"zone.js": "~0.11.8"
},
Current look of the project: