I am using ngTagsInput which has an auto-complete feature. It seems to be working very well. My problem is I want to know how to pass the query from source="loadTags(query)" into the directive, but query is always undefined. Query should simply be whatever text is typed in the search box.
Angular:
app.directive('tag', function($q) {
return {
restrict: 'E',
templateUrl: 'tag.html',
link: function (scope) {
scope.tags = [
{ text: 'Tag1' },
{ text: 'Tag2' },
{ text: 'Tag3' }
];
scope.loadTags = function(query) {
console.log(query)
var deferred = $q.defer();
deferred.resolve([{ text: 'Tag9' },{ text: 'Tag10' }]);
return deferred.promise;
};
}
}
});
HTML:
<tags-input ng-model="tags">
<auto-complete source="loadTags(query)"></auto-complete>
</tags-input>
<p>Model: {{tags}}</p>
My Plunker: http://plnkr.co/edit/3UuRok?p=info