【发布时间】:2019-06-26 11:07:41
【问题描述】:
我有一个列表,它正在遍历数组,其中有一个输入标签如何在单击按钮后从文本框中读取值,其中输入框是从列表的长度生成的
<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");
}
堆栈闪电战链接link to edit
【问题讨论】:
-
angular.io/guide/forms-overview。我投了反对票,因为我认为您还没有阅读任何文档
标签: angular typescript loops angular-ngmodel