自动完成不工作,抛出错误元素.自动补全不是一个功能
Auto complete not working it is throwing an error iElement.autocomplete is not a function
我正在尝试使用Angularjs构建一个自动完成搜索文本框。而是得到一个错误元素。自动补全不是一个功能
代码 <body ng-controller='FriendController'>
<form ng-submit="addFriend()">
<input type="email" auto-complete ui-items="fbFriends" ng-model="friend" autofocus />
</form>
<ul ng-repeat="friend in friends">
<li>
{{friend.text}}
</li>
</ul>
<script>
var addFriendAppModule = angular.module('addFriendApp', []);
addFriendAppModule.controller('FriendController',
function($scope) {
var friendArr = [];
$scope.fbFriends = [
{
value: "manu",
email: "sept@gmail.com"
},
{
value: "manu123",
email: "sept123@gmail.com"
}
];
$scope.friends = friendArr;
$scope.friend = '';
$scope.addFriend = function() {
var newFriend = $scope.friend.trim();
if (newFriend.length === 0) {
return;
}
friendArr.push(
{text: newFriend}
);
};
});
addFriendAppModule.directive('autoComplete', function($timeout) {
return function(scope, iElement, iAttrs) {
iElement.autocomplete({
source: scope[iAttrs.uiItems],
focus: function(event,ui) {
iElement.val(ui.item.email);
return false;
},
select: function(event, ui) {
iElement.val(ui.item.email);
return false;
// iElement.trigger('input');
// iElement.trigger('submit');
}
}).data("autocomplete")._renderItem = function(ul, item) {
return $("<li></li>")
.data( "item.autocomplete", item )
.append(item.email)
.appendTo(ul);
};
}
});
谁能告诉我我错过了什么?我也尝试过数据主义者html5标签的自动完成,但它没有在IE8上工作。所以我放弃了这个方法。如果有人有更好的自动补全方法,请分享。
它不能工作,因为IE8不支持HTML5,而且在当前版本的angularjs中,他们已经放弃了对IE8的支持。检查在这里。
相关文章:
- 按下一个HTML按钮,该按钮使用一个功能在同一个新窗口中打开URL
- 使用Jquery创建一个具有单击和悬停功能的菜单
- Navgoco不是一个影响密码保护页面的功能
- 如何创建一个脚本,该脚本给定网站列表,它使用其搜索功能来获取信息
- 一个按钮中的两个onClick功能,并希望一个接一个地发生一个单击功能
- 重置功能,因此一次只有一个打开
- 具有双重功能的按钮:在_blank窗口中打开一个链接,再加上_self中的另一个链接
- 使用单选按钮参考另一个功能
- 一个Ajax函数能产生另一个Ajax功能吗
- 流星:移除不是一个功能
- 通过模糊功能传递链接,而不是单击另一个链接
- 使jQuery自动完成功能适用于多个单词(“跳过”一个单词)
- 浏览器同步摄像头加速视频播放不是一个功能
- 谷歌应用程序脚本搜索UI下一个和上一个功能
- 如何阻止一个Submit按钮运行Submit Click功能
- 如何使用上一个/下一个功能循环数组中的图像
- 是否可以设置一个功能“;联系我们”;页面使用HTML/CSS
- 最有效:不同的功能/一个功能有案例
- 我正试图找出如何使我的功能一个接一个地运行.但这并没有奏效
- Grails ajax功能——一个“恼人的bug”