Itsik Mauyhas Itsik Mauyhas - 6 months ago 98
jQuery Question

angular.js - iElement is not a function

I am trying to implement auto-complete using autoComplete Directive.
Here is my

directive
:

angular.module('myApp', []).directive('autoComplete', function($timeout) {
return function(scope, iElement, iAttrs) {
iElement.autocomplete({
source: scope[iAttrs.uiItems],
select: function() {
$timeout(function() {
iElement.trigger('input');
}, 0);
}
});
};
});


The error is
undefined is not a function
for
iElement
.
I had included
angular
and
jQuery
in my app but my angular version is
1.3
(unlike the example)is this is the reason? is so there is a fix for it?

Answer

You need to wrap iElement with $(), like so

$(iElement).trigger('input');