Reputation: 199
I'm using Meterial Angular FormField. How do I remove defaulve in my form:
<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
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