Я хочу автоматически установить средство выбора даты на текущую дату, когда пользователь открывает диалоговое окно, и я не знаю, как это сделать.
Кроме того, я могу выполнить проверку Code_personnel, которая проверяет, если Code_personnel = ровно 4 символа, поэтому мне нужно использовать какой тип атрибутов проверки?
my html:
<form [formGroup]="profileForm" class="event-form w-100-p" fxLayout="column" fxFlex>
<div fxFlex="1 0 auto" fxLayout="column" fxLayout.gt-xs="row">
<mat-form-field appearance="outline" class="pr-sm-8" fxFlex="50">
<mat-label>Code personnel*</mat-label>
<input matInput formControlName="Code_personnel">
<mat-error>Code personnel doit composer par 4 chiffres.</mat-error>
</mat-form-field>
<mat-form-field appearance="outline" class="pr-sm-8" fxFlex="50">
<mat-label>N de tel</mat-label>
<input matInput formControlName="N_tel">
</mat-form-field>
</div>
<div fxFlex="1 0 auto" fxLayout="column" fxLayout.gt-xs="row">
<mat-form-field appearance="outline" class="pr-sm-8" fxFlex="100">
<mat-label>Date de naissance</mat-label>
<input matInput [matDatepicker]="startDatePicker" formControlName="birthday">
<mat-datepicker-toggle matSuffix [for]="startDatePicker"></mat-datepicker-toggle>
<mat-datepicker #startDatePicker></mat-datepicker>
</mat-form-field>
</div>
</form>
</div>
и компонент:
now;
profileForm = this.fb.group({
Nom_de_famille: ['' ,Validators.required],//
Prénom: ['' ,Validators.required],//
email: ['', [Validators.email,Validators.required]],//
Code_personnel: ['', Validators.required],//I need here aad the 4 charectres validation
N_tel: [''],
birthday: [new Date()],//I have tried that
adresse: [''],
lieu:[''],
CIN:['',Validators.required],
Genre:[''],
N_permis:[''],
Département: ['',Validators.required]
});
ngOnInit() { this.now = formatDate(new Date(), 'yyyy/MM/dd', 'en');
}