I'm wondering if there's any way to retrieve the NgModel of a FormControl pulled from the NgForm.controls object of the form to which it belongs, or retreive the NgModels from the form directly.
I have a form that, upon submit, I pass in as a parameter to a function I've defined:
<form #myForm="ngForm" name="myForm" (ngSubmit)="myFunc(myForm)">
<input type="text" name="myInput" ngModel #myInput="ngModel">
</form>
myFunc(form) {
form.controls // Gets me {[key: string]: FormControl}
}
I want to be able to set properties to my controls retrieved from the form (as NgModels) and reference them in the template with:
{{ myInput.myProp }}
as opposed to:
{{ myInput.control.myProp }}
The overall goal being to set a custom property to each NgModel of a form when it's submitted, without having to pull that property from its underlying control. Is this possible and/or am I just going about it in the wrong way altogether?