如何使用AngularJS在App Framework中实现自动完成文本框, 自动完成方法提供错误未定义
使用AppFramework时,以下代码会引发错误:
$scope.complete = function () {
console.log($scope.availableTags);
$("#tags").autocomplete({ source: $scope.availableTags });
};
错误autoComplete方法未定义
答案 0 :(得分:0)
您可以使用ng-autocomplete
。我提供了一个简单的例子如下:
<!DOCTYPE html>
<html ng-app="Test">
<head>
<meta name="viewport" content="initial-scale=1.0, user-scalable=no" />
<link rel="stylesheet" href="//netdna.bootstrapcdn.com/bootstrap/3.0.0/css/bootstrap.min.css">
<link rel="stylesheet" type="text/css"href="style.css">
<script type="text/javascript" src="http://maps.googleapis.com/maps/api/js?libraries=places&sensor=false"></script>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/angularjs/1.0.8/angular.js"></script>
<script src="script.js"></script>
<script src="ngAutocomplete.js"></script>
</head>
<body>
<div ng-controller="TestCtrl">
<form id="form" role="form">
<div class="form-group move-down">
<label for="Autocomplete">Generic Autocomplete</label>
<input type="text" id="Autocomplete" class="form-control" ng-autocomplete="result1" details="details1" options="options1"/>
</div>
</form>
</div>
</body>
</html>
您也可以使用Angucomplete。在此处找到它:http://ghiden.github.io/angucomplete-alt/