Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ng-tags-input, storing tags data as a string array

I'm using ng-tags input, and the data I get after populating a line is an array of object, each with one 'text' string field like so

[{"text":"egon"},{"text":"peter"},{"text":"raymond"},{"text":"winston"}]

Is there a way to store the data as an array of strings instead? like

["egon", "peter", "raymond", "winston"]
like image 905
svarog Avatar asked Feb 10 '15 10:02

svarog


1 Answers

ngTagsInput only works with arrays of objects. You can easily extract an array of strings out of an array of objects, though:

$scope.tagsString = $scope.tags.map(function(tag) { return tag.text; });

Update

It took some time, but ngTagsInput offers now basic support for array of strings. Starting in v3.2.0, the following is possible:

<tags-input ng-model="tags" use-strings="true"></tags-input>

Plunker

Better late than never, I guess.

like image 176
Michael Benford Avatar answered Oct 31 '22 09:10

Michael Benford