I want to create a text field that uses the autocomplete typeahead for ui- angular, I want the autocomposition to work every time I type the ";" key, for example: when I type "anny" in the text box, all contact email appears containing "anny", I select the one I want, and when I type the key ";" I can use autocomposition again (like Outlook) ... I already created a text box, but it only works for email address
<div class="form-group" ng-class="{'has-error':NewRequest.BeneficiaryId.$invalid}">
<label for="inputEmail3" class="col-lg-2 control-label"> Email:</label>
<div class="col-sm-10">
<input type="text" name="BeneficiaryId"
ng-model="Ticket.BeneficiaryId" placeholder="Email"
typeahead="address as address.Email for address in Form.autoComplete($viewValue) | filter:$viewValue"
typeahead-loading=" loadinglocations"
class="form-control" required>
<i ng-show="loadingLocations" class="glyphicon glyphicon-refresh"> </i>
</div>
And what is my autocomplete service
services.service('Form', function ($http, $q, $modal) {
this.autoComplete = function (val) {
var deferred = $q.defer();
$http.get("../api/Employee/getAutocomplet", {
params: {sSearch: val }
}).then(function (response) {
var addresses = [];
angular.forEach(response.data, function (item) {
addresses.push(item);
});
deferred.resolve(addresses);
});
return deferred.promise;
};
source
share