I’m trying to pass data from form input fields to be used in a function within my component using ngForm and ngModel. However I get the following error:
self.context.hello is not a function
here is my code:
In the view
<form novalidate (ngSubmit)="onSubmit(myForm)" #myForm="ngForm">
<div *ngFor=" let selectedService of selectedService.params ">
<ion-item *ngFor=" let key of selectedService | keys ">
<ion-label floating>{{key}}</ion-label>
<ion-input type="number" name="{{key}}" ngModel></ion-input>
</ion-item>
</div>
<button ion-button type="submit" block>{{selectedService.name}}</button>
</form>
@THIERRYSCO Thanks for your input. This method would work under normal circumstances, but if you notice from my code I am iterating over an associative array of parameters (key-value pairs) to create input fields and “name” those input fields according to their array keys and return the input values with the onclick function. The problem here is I will not always know how many parameters there would be nor know what the keys those parameters would be called; therefore I cannot statically define a model in the component to handle the form submission.
@THIERRYSCO Hello!! Problem solved. Thanks for your input though; turns out that I was doing the right thing all this while, but I was working on the wrong file (the temporary version of my .ts file - I feel so silly right now). This explains why it was not finding the function. Thanks a lot for the help