I was on the right track. I just had the arguments wrong.
To update the width or height of an open dialog, you get a reference to the open dialog and call the updateSize method. The first parameter sets the width and the second parameter sets the height. Both are of type string.
import { Component, OnInit, Inject } from '@angular/core';
import { MatDialogRef, MAT_DIALOG_DATA } from '@angular/material';
@Component({
selector: 'app-my-dialog',
templateUrl: './my-dialog.component.html'
})
export class MyDialogComponent implements OnInit {
private shouldSizeUpdate: boolean;
constructor(private dialogRef: MatDialogRef<MyDialogComponent>,
@Inject(MAT_DIALOG_DATA) data: any) {
this.shouldSizeUpdate = data.shouldSizeUpdate;
}
ngOnInit() {
if (this.shouldSizeUpdate) this.updateSize();
}
updateSize() {
this.dialogRef.updateSize("300px", "500px");
}
}
And the code for further reference.
/**
* Updates the dialog's width and height.
* @param {?=} width New width of the dialog.
* @param {?=} height New height of the dialog.
* @return {?}
*/
MatDialogRef.prototype.updateSize = function (width, height) {
if (width === void 0) { width = 'auto'; }
if (height === void 0) { height = 'auto'; }
this._getPositionStrategy().width(width).height(height);
this._overlayRef.updatePosition();
return this;
};