0
votes

I got the Angular Material Mat-Select dropdown almost working for binding the selected dropdown value to the object property. However, When I check in the callback function to check on the object property value, it is blank. When the object property value is blank, it triggers the mat-error which shows the red error message. I added a doSomething function to check on the dropdown value and the value from (valueChange) is blank and the object property field is also blank.

I looked at the examples on the material site but nothing is giving a clue on what is the issue with my code. Hoping someone can help. Thanks.

<mat-select [(ngModel)]="myObject.Record.code" 
                                [disabled]="!myObject.required"

                                (valueChange)="doSomething($event)"

                                [formControl]="myCtrl" required>
                      <mat-option [value]="myObject.Record.code">{{myObject.Record.code}}</mat-option>
                      <mat-option *ngFor="let option of options" 
                      [value]="option">{{reason.name}}</mat-option>
                    </mat-select>
1

1 Answers

0
votes

Sorry, After looking at the material site, I figure out my error, the following binded code fix is

{{reason.name}}

Hope this help someone else.