I have a form with some input in a loop with lang and when I submit the form, the name of the input is a string rather than an object. Is it possible to return an object or what's the best way to create this object to send to an api?
My template
<form class="kt-form" (ngSubmit)="onSubmit(f)" #f="ngForm">
<label>Name</label>
<input *ngFor="let lang of aLang"
type="text"
class="form-control"
name="translations.{{lang}}.name"
ngModel
>
<button type="submit" class="btn btn-primary">Submit</button>
</form>
In my component
onSubmit (form: NgForm){
let datas = form.value;
console.log(datas);
}
Now, I have this result:
Object { "translations.fr.name": "", "translations.nl.name": "", "translations.en.name": "" }
Thanks for your help !
translations.{{lang}}.nameor this as a string?