I'm encountering an issue with the "auto-complete" directive that I'm using from jsfiddle. The error message I'm receiving is
iElement.autocomplete is not a function
. Can someone help me troubleshoot and fix this error?
directive.js
starter.directive('autoComplete', function($timeout) {
return function(scope, iElement, iAttrs) {
iElement.autocomplete({
source: function(request, response) {
var res = new Array()
for (var i=0; i<scope[iAttrs.uiItems].length; i++) {
if (scope[iAttrs.uiItems][i].indexOf(request.term) == 0) {
res.push(scope[iAttrs.uiItems][i]);
}
}
response(res);
},
select: function() {
$timeout(function() {
iElement.trigger('input');
}, 0);
}
});
};
});
.html file
<input type="text" auto-complete="true" ui-items="names" ng-model="selected" class="tagdiv" style="color:#fff" placeholder="Tag your category">
.js file
$scope.names = ["john", "bill", "charlie", "robert", "alban", "oscar", "marie", "celine", "brad", "drew", "rebecca", "michel", "francis", "jean", "paul", "pierre", "nicolas", "alfred", "gerard", "louis", "albert", "edouard", "benoit", "guillaume", "nicolas", "joseph"];