2016-05-23 29 views
0

我试图使用autoComplete Directive实现自动完成。 这里是我的directiveangular.js - iElement不是函数

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); 
       } 
      }); 
    }; 
}); 

的错误是undefined is not a functioniElement。 我在我的应用中包含了angularjQuery,但我的角度版本是1.3(不像示例),这是原因吗?是否有这样的解决方案?

+0

给我们,错误的例子。 – WorkWe

+0

其实你的例子工作没有任何错误对我来说 - http://jsfiddle.net/swfjt/4935/ – shershen

+0

它工作正常与我:) – WorkWe

回答

0

你需要用iElement与$(),像这样

$(iElement).trigger('input'); 
相关问题