How can I allow email address input to accept multiple email addresses in Angular

Viewed 1646

I am working on an Angular system doing enhancement and one of the changes I have to do is to allow email address input to accept multiple email addresses. I did a deep dig on the net to get some ideas but I don't seem to see the angular one. I am getting Jquery examples only.

How can I allow email address input to accept multiple email addresses?

Example or similar thing I want

What I have done:

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.';
        });
        }
        }
1 Answers
Related