添加空格分隔标签时,ng-tags-input将用破折号替换空格。如何保留空格字符呢?
我刚刚在文档中找到了相应的指令属性。答案:使用replace-spaces-with-dashes=false
为了用下划线替换空格,我做了以下操作:
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;
};