AngularJS value not passing to directive -


i using ngtagsinput has auto-complete feature. seems working well. problem want know how pass query source="loadtags(query)" directive, query undefined. query should whatever text typed in 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

this fix you:

change

<auto-complete source="loadtags(query)"></auto-complete> 

to

<auto-complete source="loadtags($query)"></auto-complete> 

see updated plunker.


Comments

Popular posts from this blog

javascript - jquery or ashx not working -

opencv - DataType<cv::detail::deriv_type>::depth what is it used for -

python 3.x - Mapping specific letters onto a list of words -