Hello and thank you for taking the time to read my question!
I am currently working on an Ionic 3 app project. One of the features in this app involves a page that can have up to 200 identical forms, each containing an input field. You can see an example of what I mean by visiting this link: ionic page with repeated forms. To help clarify the placement of the input spaces, I labeled them as "input3," "input4," and so on.
The number of these forms displayed on the page is determined by the user through a settings modal, which means I cannot hard-code them statically into the HTML markup. In order to achieve this dynamic functionality, I utilized the following code snippet in my HTML:
<form>
<ion-row *ngFor="let y of rowCount|times" text-center align-items-center>
<ion-col align-self-center col-2>{{y}}</ion-col>
<ion-col text-center align-self-center col-4><ion-input id='input{{y}}'
formControlName="input{{y}}" [(ngModel)]="inputy"></ion-input></ion-col>
<ion-col align-self-center col-4>{{status}}</ion-col>
<ion-col align-self-center col-2><button
id= 'button{{y}}' ion-button small icon-only>
<ion-icon name="brush"></ion-icon></button></ion-col>
</ion-row>
</form>
To repeat the rows based on the value stored in the variable rowCount
, I implemented a Custom Pipe
named times
.
While I was successful in dynamically generating attributes such as id
, formControlName
, and ngModel
within the HTML, I am facing a challenge in accessing these dynamically created values from the TypeScript file associated with this component. Can you provide guidance on how I might retrieve the values of each dynamically generated formControlName
in the TypeScript code? Additionally, is there a way to extract the values from the dynamically generated ngModel
?