Newbiiiie
Newbiiiie

Reputation: 1491

Make an Editable ReactiveForm with asynchronus Data

I use angular CLI 1.6 and angularfire2.

I have this reactive form :

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

And i want pre-populate the form with asynchronous data.

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

ppssToDisplay is an observable. How i can do this ?

Upvotes: 1

Views: 84

Answers (1)

Rohan Kumar
Rohan Kumar

Reputation: 40639

Try to use setValue on your form control in your observable like,

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

Also the article is helpful for you to handle async data.

Upvotes: 1

Related Questions