【发布时间】:2020-12-10 06:28:07
【问题描述】:
我有一个场景,输入字段中的 应该接受数组中存在的值。如果添加其他值,它应该会抛出错误。
.component.html
<input type="text" ([ngModel])="InputValues" (blur)="validate()">
.component.ts
arrayList = ['table_1', 'table_2', 'table_3', 'table_4'];
arrayList 有 4 个元素,如果输入任何其他值会引发错误,则输入字段应仅接受此值。输入应接受存在于 arrayList 中的值。
【问题讨论】:
标签: javascript jquery angular regex