I have the following in HTML
<mat-form-field [appearance]="matFormFieldAppearance" style="margin-left:10px;width:50%">
<mat-label>Type</mat-label>
<mat-select formControlName="TypeId" required>
<mat-option *ngFor="let item of TypeList" [value]="item.Id">
{{item.Title}}
</mat-option>
</mat-select>
</mat-form-field>
<mat-form-field [appearance]="matFormFieldAppearance" style="margin-left:10px;width:50%">
<mat-label>Category</mat-label>
<mat-select formControlName="CategoryeId" required>
<mat-option *ngFor="let item of CategoryList" [value]="item.Category">
{{item.Category}}
</mat-option>
</mat-select>
</mat-form-field>
In TypeScript, MatDialog receives data and if Field1 is not null then, I want the form fields be put in ReadOnly
this.K = this.matdialogData;
if (this.K.Field1 !== null)
{
this.myForm.controls.CategoryeId.ReadOnly(); //Something like this
this.myForm.controls.TypeId.ReadOnly();//Something like this
}