ui-select2, , . - angular, select2 , . :
<input type="text" tag-list ng-model="item.tags">
, item.tags - javascript, - . ( ui-select2, 2):
app.directive('tagList', function($timeout) {
return {
require: 'ngModel',
restrict: 'A',
link: function(scope, element, attrs, controller) {
scope.$watch(attrs.ngModel, function(value) {
if (value !== undefined) {
element.select2('val', value);
}
});
element.bind('change', function() {
var value = element.select2('val');
controller.$setViewValue(value);
});
$timeout(function() {
element.select2({
tags: []
});
});
}
};
});