【问题标题】:How can I allow email address input to accept multiple email addresses in Angular如何允许电子邮件地址输入在 Angular 中接受多个电子邮件地址
【发布时间】:2021-02-11 09:34:48
【问题描述】:

我正在开发一个 Angular 系统进行增强,我必须做的更改之一是允许电子邮件地址输入接受多个电子邮件地址。我在网上进行了深入挖掘以获得一些想法,但我似乎没有看到有角度的想法。我只获取 Jquery 示例。

如何让邮箱地址输入接受多个邮箱地址?

Example or similar thing I want

我做了什么:

HTML

   <div>
     <input name="contactEmail" placeholder="Contact Email" formControlName="contactEmail" 
     class="input- group input-group-md" type="text" [(ngModel)]="newCustomer.email" multiple>                  
  </div>

Component.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.';
        });
        }
        }

【问题讨论】:

    标签: html angular input


    【解决方案1】:

    您正在寻找的是筹码。 我建议你不要自己实现这个,你会遇到很多问题(不要问我是怎么知道的)。

    您可以使用现有的库,例如

    【讨论】:

    • 我使用的是版本 (7.3.10)。使用本地 Angular CLI 版本。这将如何运作?你能指导我如何实现这个吗?
    • 查看例如 Ngx 芯片并浏览文档。
    • 我已经成功地设置了这个例子,它工作正常。但我不知道如何将 ti 转换为我当前的代码。你能帮我把它转换成我现在的代码吗?
    猜你喜欢
    • 2015-01-23
    • 2010-12-04
    • 2018-08-21
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-06-07
    • 2017-07-23
    • 1970-01-01
    相关资源
    最近更新 更多