12

I have an email sending scenario in which there is an input box of 'To'(whom you want to send a message).

app.html

 <input type="text" class="form-control" [(ngModel)]="email.Tos"> 

Now I want that when a user input the multiple emailId in input box by comma separated, then in my model, 'Tos' value should bind in an Array of string. Like : ["abc@gmail,com" , "[email protected]"].

Now, please tell me how to split the input box value as per my requirement.

1 Answer 1

20

You need to use split() function.

Component

let toArray =  this.email.Tos.split(",");

variable toArray will contain an array of emails.

Please check split

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.