I am working on a list that iterates over an array and includes input tags. I need to figure out how to retrieve the values from the text boxes after clicking a button, as the input boxes are generated based on the length of the list.
<div>
<div *ngFor="let arrayitems of arrayElements">
<P>{{arrayitems}}</P>
<input type ="text" placeholder="{{arrayitems}}">
</div>
<button (click)="submitFunction()" style="margin-top:10px">CLICK ME!</button>
</div>
TypeScript:
arrayElements : any;
ngOnInit(){
this.arrayElements=["listElementOne","listElementTwo","listElementThree","listElementFour","listElementFive","listElementSix"];
}
submitFunction(){
alert("Function Called");
console.log("print all the values taken from the input tag");
}
Access the Stack Blitz Link here