Felippe Nardi
Felippe Nardi

Reputation: 605

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?

Upvotes: 5

Views: 2483

Answers (2)

Artem Halas
Artem Halas

Reputation: 163

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;
};

Upvotes: 3

Felippe Nardi
Felippe Nardi

Reputation: 605

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

Upvotes: 8

Related Questions