I'm creating a form with input fields. There are some default inputs fields values that come from a REST API.
Here is my template :
<form [formGroup]="form" (ngSubmit)="action()">
<input type="text" formControlName="name" [value]="fromApi(name)">
</form>
And my TS code :
this.form = new FormGroup({name:new FormControl('')})
The client got his default value from the API. He can change that data in the input field.
There are two possibilities :
1) He does change the initial value coming from the API. In that cas when I console.log the FormGroup, I got the new value he entered, that's perfect !
2) He doesn't want to change the value from the API. And that's my problem : in that case, the value for the input name is '' (the value from FormControl). And I would like to have the value from the API.
Is it possible ? Thanks