Reputation: 819
Currently, I am making use of ngTagsInput directive for my search bar. However, I am having trouble finding a way to clear results on selection or prevent the tags from rendering in the search bar.
This is what I currently have:
And this is what I'm trying to get:
I tried writing a directive to detect enter key press down and then use myEnter=$('tags-item').remove() to try and remove the element as it was being created, but not only did it not work, it's also not ideal:
app.directive('myEnter', function () {
return function (scope, element, attrs) {
element.bind("keydown keypress", function (event) {
if(event.which === 13) {
scope.$apply(function (){
scope.$eval(attrs.myEnter);
});
event.preventDefault();
}
});
};
});
Upvotes: 0
Views: 826
Reputation: 1273
I don't know why you are using this component while you don't actually want the tags.
anyway, you don't need that custom directive. on-tag-added can pretty much cover all you need.
i.e. on , add
on-tag-added="tagAdded($tag)"
in controller
$scope.tagAdded = function(tag) {
//just do whatever you want on tag added,
//i.e. clear the ngmodel and add it to another array, etc.
};
Upvotes: 1