我的文本框看起来像这样..
<div class="col-md-8" ng-class="{ 'has-error' :
TicketSupportForm.TicketNo.$invalid && !TicketSupportForm.TicketNo.$pristine }">
<input type="text" ng-keyup="Autocomplete(TicketNo)" class="form-control" id="txtTicketNo" placeholder="Ticket Number"
name="TicketNo" ng-model="TicketNo" required>
</div>
Js Code Here
$scope.Autocomplete = function (id) {
debugger
$http.get("/api/TicketSupport/GetTicketIDForAutoComplete?TransID=" + id)
.success(function (data, status, headers, config) {
if (data != "") {
//console.log(data[0].TransID);
$("#txtTicketNo").autocomplete({
status: data[0].TransID
});
}
});
}
在上面的代码“GetTicketIDForAutoComplete”函数中从DB获取数据。 data [0] .TransID也获取值.. 但它显示错误“自动完成”不是一个功能
我已经添加了js标签
<link rel="stylesheet" href="//code.jquery.com/ui/1.11.2/themes/smoothness/jquery-ui.css" />
<script src="//code.jquery.com/jquery-1.10.2.js"></script>
<script src="//code.jquery.com/ui/1.11.2/jquery-ui.js"></script>
答案 0 :(得分:2)
检查一下,
[http://jsfiddle.net/sebmade/swfjT/light/][1]
在Material design中,您可以创建时尚的自动填充文本框 https://material.angularjs.org/latest/demo/autocomplete