html - 如何允许电子邮件地址输入在 Angular 中接受多个电子邮件地址
问题描述
我正在开发一个 Angular 系统进行增强,我必须做的更改之一是允许电子邮件地址输入接受多个电子邮件地址。我在网上进行了深入挖掘以获得一些想法,但我似乎没有看到有角度的想法。我只得到 Jquery 示例。
如何允许电子邮件地址输入接受多个电子邮件地址?
我做了什么:
HTML
<div>
<input name="contactEmail" placeholder="Contact Email" formControlName="contactEmail"
class="input- group input-group-md" type="text" [(ngModel)]="newCustomer.email" multiple>
</div>
组件.ts
public newCustomer: any = {
name: undefined,
cont1: undefined,
email: [],
phone1: undefined,
balance: 0.0
};
onCustomerSubmit() {
if (!this.addCustomerForm.invalid) {
//other code
this.customerService.addCustomer(this.newCustomer, true, this.seller.name).then(data => {
console.log("This is the data: " +data)
if (data != null) {
this.loadCusromers();
this.onCustomerReset();
this.messageService.add({ severity: 'success', summary: 'New Customer', detail:
'Customer is added successful.' });
this.getCustomers();
} else {
if (data.faultcode === 'Server.Customer.duplicate_name') {
this.addAccountError = 'There is already exsisting custmer with the same name.';
}
}
this.isAddingCustomer = false;
}).catch(error => {
this.isAddingCustomer = false;
this.addAccountError = 'We are unable to process your request at this time. please try
again later.';
});
}
}
解决方案
你要找的是芯片。我建议你不要自己实现这个,你会遇到很多问题(不要问我是怎么知道的)。
您可以使用现有的库,例如
推荐阅读
- vba - VBA中自调用函数中的返回数组
- ios - 使用 MDCMultilineTextField 的带有边框和浮动占位符的 UITextView
- java - Spring MessageSource:访问依赖jar中的消息文件
- javascript - 在本机反应中使用redux将输入从大写转换为小写
- java - 不同输入的二维码可以相同吗?
- react-testing-library - 如何使用 useEffect 和 useRef 挂钩将焦点设置到反应组件中的 div 元素?以及如何测试它?
- node.js - 带有 TypeScript 的 Azure Functions 的 Hello World 应用程序无法使用 VSCode 启动
- assembly - 检查输入是否是汇编语言中的字母、数字或特殊字符
- django - 将模板中的 id = "" 添加到 'HttpResponseRedirect (reverse ('name_view'))'。姜戈
- c# - 具有 2 个过滤参数的 MVC 控制器