Skip to content

Instantly share code, notes, and snippets.

@alovak
Last active December 18, 2015 22:59
Show Gist options
  • Save alovak/5858400 to your computer and use it in GitHub Desktop.
Save alovak/5858400 to your computer and use it in GitHub Desktop.
App.directive('tagIt', function ($timeout) {
return {
template: "<ul class='tagit'></ul>",
replace: true,
scope: {
tags: "=",
},
link: function(scope, element) {
$(element).tagit({
afterTagAdded: function(event, ui) {
scope.tags = element.tagit("assignedTags");
scope.$apply();
},
afterTagRemoved: function(event, ui) {
scope.tags = element.tagit("assignedTags");
scope.$apply();
}
});
scope.tags.forEach(function(tag) {
$(element).tagit('createTag', tag);
})
}
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment