1

I'm trying to allow users to paste a list that is separated by , ; or | using ngx-chips.

There is an option to do this with pasteSplitPattern - [?string | RegExp]

https://github.com/Gbuomprisco/ngx-chips

When I try the following though, I get an error

[pasteSplitPattern]="[,|;]"

Parser Error: Unexpected token , 

What should I be doing differently?

user749798
  • 5,210
  • 10
  • 51
  • 85

3 Answers3

5

Try using the following:

Define a new regex :

splitPattern = new RegExp('[\,\;]');

and then use it in your template:

[pasteSplitPattern]= "splitPattern"
1

I had the same problem : you have to add [addOnPaste]="true" to make it work!

buddemat
  • 4,552
  • 14
  • 29
  • 49
  • This solution only includes the separation pattern by ",". To add a new pattern you must also use [pasteSplitPattern]="splitPattern" – Pablo Arak Nov 15 '21 at 14:10
0

use the below to separate by comma or enter

[separatorKeyCodes]="[32, 188]"
shanthan
  • 554
  • 8
  • 8