andrzej andrzej - 2 months ago 20
AngularJS Question

ngTagsInput get and parse data from database

When I use ngTagsInput before send to database I do:

angular.toJson($scope.tags);


When I make get I receive something like this in my scope {{}}:

[{"text":"abc"},{"text":"cba"},{"text":"tag"}]


What can I do to show my tags like this:

abc, cba, tag

Answer

In the template:

<span ng-repeat="(key, value) in tags"><span ng-if="!$first">, </span><span>{{value.text}}</span></span>

Or with Underscore in code:

var str = _.pluck(list, 'text').join(', ')

Other options here: Show an aggregated list in angularjs

Comments