Html 如何显示从后端到角度材质日期选择器字段的日期?
我有一张从后端数据填写的表格,我所有的档案都可以,但是生日档案没有从后端给我带回日期。我使用角材料和日期选择器 我在我的组件中这样填写表格Html 如何显示从后端到角度材质日期选择器字段的日期?,html,angular,typescript,datepicker,angular5,Html,Angular,Typescript,Datepicker,Angular5,我有一张从后端数据填写的表格,我所有的档案都可以,但是生日档案没有从后端给我带回日期。我使用角材料和日期选择器 我在我的组件中这样填写表格 Birthday: [this.client.Birthday] 这是我的html文件 <div class="mb-24" fxLayout="row"> <mat-form-field fxFlex> <input matInput name="Birthday" [(ngMo
Birthday: [this.client.Birthday]
这是我的html文件
<div class="mb-24" fxLayout="row">
<mat-form-field fxFlex>
<input matInput name="Birthday" [(ngModel)]="client.Birthday" formControlName="Birthday" placeholder="Ditëlindja" [matDatepicker]="picker" tabindex="13">
<mat-datepicker-toggle matSuffix [for]="picker"></mat-datepicker-toggle>
<mat-datepicker #picker></mat-datepicker>
</mat-form-field>
</div>
如何从后端获取日期并显示到html,当我发出put请求时,我的日期可以转到后端并更改日期,但当我想在更新表单中查看日期时,它们不会显示。我认为问题在于
[matDatepicker]
您提供的代码中没有足够的信息来确定答案,但我猜当您从后端获得客户端时,您并没有更新生日
的值;这是我的呼叫以获取客户端您将this.client.birth
作为birth
表单控件的默认值。如果this.client
在构建表单组时为空,birth
的值即使在从后端返回数据后也将未定义。您需要执行this.myF订阅中的ormGroup.get('birth').setValue(client.birth);
。