dinosaur
dinosaur

Reputation: 199

How to remove [object Object] in mat-form-field Angular Meterial

I'm using Meterial Angular FormField. How do I remove defaulve in my form:

enter image description here

<mat-form-field appearance="fill">
            <mat-label>Ngày nhận</mat-label>
            <input matInput placeholder="Ngày nhận"
                   [formControl]="ngayNhanFormControl"
                   required
            >
            <mat-error *ngIf="( ngayNhanFormControl.errors?.required)"></mat-error>
          </mat-form-field>

And this is my code:

this.ngayNhanFormControl = new FormControl({value: ''}, [Validators.required]);
...

this.theoDoiPhoiGCNFormGroup = new FormGroup({
      NgayNhan: this.ngayNhanFormControl,

Upvotes: 0

Views: 930

Answers (1)

CodeWarrior
CodeWarrior

Reputation: 5176

It is happening because you are initializing your FormControl with an object {value: ''}. Change your code to this:

this.ngayNhanFormControl = new FormControl('', [Validators.required]);

Upvotes: 2

Related Questions