您好 Stack Overflow 团队,当单击编辑链接以显示编辑客户详细信息表单时。在此表单中,除了未显示的日期选择器数据外,所有存在的数据都显示。来自 Web API 的所有数据。
EditUser.component.html
<mat-form-field class="demo-full-width">
<input matInput [matDatepicker]="picker" matTooltip="Enter Date Of Birth"
placeholder="Choose Date Of Birth" formControlName="DataOfBirth">
<mat-datepicker-toggle matSuffix [for]="picker"></mat-datepicker-toggle>
<mat-datepicker #picker></mat-datepicker>
</mat-form-field>
编辑用户.component.ts
this.service.getRegistrationDetails(this.registrationId).subscribe(data => {
this.updateUserForm.controls['First_Name'].setValue(data.FirstName);
const dateOfBirth = this.datePipe.transform(data.DataOfBirth.toString(), 'MM/dd/yyyy');});
服务.ts
getRegistrationDetails(registrationId: string): Observable<Register> {
// debugger;
return this.http.get<Register>(this.url + '/GetRegistration/' + registrationId);
}