angular - Angular Textinput 组件不适用于数组
问题描述
我想要一个文本输入组件的集合,其值存储在一个数组中。但是当我使用下面的代码时,值在数组中的位置错误,我找不到错误。
<table>
<tr *ngFor="let option of this.options;let i = index">
<td style="width:100%">
<textinput2 (textchange)="this.options[i] = $event;" class="lessmargin" type="text" [value]="this.options[i]">
</textinput2>
</td>
<td valign="top">
<button [attr.disabled]="this.options.length >= 3 ? null:''" (click)="this.options.splice(i, 1)" style="top:0;" class="btn btn-outline-danger">-</button>
</td>
</tr>
</table>
<a (click)="this.options.push('')" class="showmore">+ weitere Option hinzufügen</a>
Textinput2 组件:
<div class="form-group">
<label *ngIf="this.placeholder && this.labelsize == 'big'" for={{randomid}}><h5>{{this.placeholder}}</h5></label>
<label *ngIf="this.placeholder && this.labelsize == 'small'" for={{randomid}}>{{this.placeholder}}</label>
<input [(ngModel)]="this.value" (change)="this.textchange.emit(this.value)" type={{type}} id={{randomid}} class="form-control" placeholder={{this.placeholder}}>
</div>
谢谢
解决方案
推荐阅读
- visual-studio-code - 按下回车键时如何阻止 VS Code 从 {% ... %} 语句中删除大括号?
- python - Beautifulsoup - 从包含 h4 的特定类中抓取
- node.js - 如何从 node.js 中未分页的 API 获取数据
- talend - 在 Talend 中的 Joblet 完成之前运行的 PostJob 和 Main 作业
- javascript - 如何使用 javascript 显示 google recaptcha 错误消息
- python - 启动内核时发生错误。蜘蛛,张量流
- javascript - 如何找出这个 div 标签的反应数字?
- svelte - 如何从 DOM 结构中删除随机的 svelte-preprocess 类?
- html -
线高和高度子像素差
- mysql-8.0 - 如何为子查询设置每行主键