Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to change ng-tags-input separator? (default: dash)

When adding a space-separated tag, ng-tags-input will replace the space with a dash. How can I keep the space character instead?

like image 995
Felippe Nardi Avatar asked Jun 09 '15 18:06

Felippe Nardi


2 Answers

I've just found the corresponding directive property on the documentation. Answer: use replace-spaces-with-dashes=false

like image 109
Felippe Nardi Avatar answered Sep 18 '22 09:09

Felippe Nardi


In order to replace spaces with underscores, I did the following:

HTML:

<tags-input ng-model="model" replace-spaces-with-dashes="false" on-tag-adding="addingTag($tag)"></tags-input>

JS:

$scope.addingTag = function(tag) {
  tag.text = tag.text.replace(/ /g, '_');
  return tag;
};
like image 39
Artem Galas Avatar answered Sep 21 '22 09:09

Artem Galas