使用异步数据制作可编辑的反应式表单

Make an Editable ReactiveForm with asynchronus Data

我使用 angular CLI 1.6 和 angularfire2。

我有这种反应形式:

<mat-form-field style="width:100%" appearance="outline">
<mat-label>Description du traitement</mat-label>
<textarea matInput formControlName="description" ></textarea>
</mat-form-field>

我想用异步数据预填充表单。

{{ (ppssToDisplay | async)?.traitement }}

ppssToDisplay 是一个可观察对象。我该怎么做?

尝试在您的 observable 表单控件上使用 setValue,例如,

....subscribe(res=>{
  this.form.controls['description'].setValue(ppssToDisplay.traitement);
});

此外 article 也有助于您处理异步数据。