How to show tags using select2 in select tag using angularjs

I want to set tags in a select2 dropdown. For example, I want to put a custom email or whatever, then it should be displayed as a tag. I am sharing a jsfiddle.

<div ng-controller="MyCtrl">
    <label>Please select items:</label>
    <select ui-select2 multiple ng-model='selectedDaltons'>
        <option ng-repeat="d in daltons" ng-bind="d" value="{{ d }}"></option>
    </select>
</div>




var myApp = angular.module('myApp', ['ui.select2']);

function MyCtrl($scope) {
    $scope.daltons = [
        'Joe',
        'William' ,
        'Jack' ,
        'Averell' ,
        'Ma' 
    ];    
    $scope.selectedDaltons = 'joe'; // Averell is preselected 
};

      

http://jsfiddle.net/hWXBv/179/

+3


source to share


1 answer


In ui-select you can use the "tagging" function, you can even set the tagging tag. Check this link.

https://github.com/angular-ui/ui-select/wiki/ui-select

      



And this plunker:

http://plnkr.co/edit/m1SQXUxftBLQtitng1f0

      

+2


source







All Articles