我有一个带有Angular.js和实体框架的c#MVC项目。 在我看来,我使用控制器进行自动完成 它运作正常。
当我专注于自动填充的文本框搜索时,我想加载下拉数据。
app.controller("HomeController", ['$scope', '$http', function ($scope, $http) {
$scope.countries = [];
$scope.SelectedCountries = null;
$scope.AfterSelectedCoutries = function (selected) {
if (selected) {
$scope.SelectedCountries = selected.originalObject;
}
}
$http.get("/Home/Get_Doctor").then(function (d) {
$scope.countries = d.data;
$timeout(function () {
var searchInput = document.getElementById('txtautocomplete');
searchInput.focus();
}, 0);
}, function (error) {
alert('Failed');
})
}])
<div class="form-group">
<label for="title" class="col-sm-2 control-label">Doctor</label>
<div class="col-sm-10">
<div ng-controller="HomeController">
<div angucomplete-alt id="txtautocomplete"
placeholder="Type Doctor name" pause="100"
selected-object="AfterSelectedCoutries"
local-data="countries" search-fields="Doctor_Name_Arabic"
title-field="Doctor_Name_Arabic" minlength="1"
input-class="form-control" match-class="highlight">
</div>