Ok, so you've got selected_item bound to ng-model and it is an object with
a property of Tags that points to an array. Instead of trying
interpolation on the value attribute of the input, make the input use
ng-model and update the value when the selected item changes with
ng-change. This is the more "angular way" of doing it.
<select ng-model="selected_item" name="select" id="gallery_list"
ng-options="v as v.Title for (k, v) in Items"
ng-change="updateTags()"></select>
<input type="text" name="Tags" ng-model="selectedTags" placeholder="Tag,
Tag 2"/>
//in the controller
$scope.selectedTags = null;
$scope. updateTags = function(){
$scope.selectedTags = $scope.selected_item.Tags.join(); //join() creates
a comma separated string of values from the array
}
On Tuesday, March 18, 2014 11:48:35 AM UTC-6, Maksim Go wrote:
>
> Hello,
>
> I need help with getting values from array into comma separated list.
>
> I have select tag: <select ng-model="selected_item" name="select"
> id="gallery_list" ng-options="v as v.Title for (k, v) in Items"></select>
>
> now if I need to get selected items tags with {{selected_item.Tags}} it
> gives me an array: {"0":" Test Tag 1","1":"Test Tag 2"}
> But since i need to display this list as input value, I don't know how to
> iterate the values in given array:
> <input type="text" name="Tags" value="{{selected_item.Tags}}"
> placeholder="Tag, Tag 2"/>
>
> Snippet what I have is like this:
> <select ng-model="selected_item" name="select" id="gallery_list"
> ng-options="v as v.Title for (k, v) in Items"></select>
> <input type="text" name="Tags" value="{{selected_item.Tags}}"
> placeholder="Tag, Tag 2"/>
>
--
You received this message because you are subscribed to the Google Groups
"AngularJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.