I tried to put the value to <input value="{{ val }}"> but I think its wrong because it returns empty data.
How can I set a default value to an input?
I already created API for update. I just really need to return the input data.
thanks
You can use one-way input binding:
<input [value]="val">
or two-way input binding:
<input [(ngModel)]="val">
One-way will give you the value, and update it when the component updates it... but will not change the value with user input.
Two-way will change on user input as well as component changes.
ngModeland do a proper binding. You can create a separate object for your form and set the initial data whenever you want (just at the start?) likethis.formData = Object.assign({}, this.data);, then useformDatawhen you submit the form leaving your originaldataunchanged.