Implement autocomplete textbox in AngularJS

This article explains how to implement an autocomplete textbox in AngularJS.

We know that AngularJS is a very popular framework nowadays for build highly interactive web applications and for making our application more interactive, we can create this autocomplete textbox in our AngularJS application.

Autocomplete textbox in AngularJS and asp.net MVC
Selected Country : {{SelectedCountry.CountryName}}
Implement autocomplete textbox in AngularJS
var app = angular.module('myApp', ['angucomplete-alt']);
app.controller('ngAutoCompleteController', ['$scope', '$http', function ($scope, $http) {
    $scope.Countries = [];
    $scope.SelectedCountry = null;
    //After select country event
    $scope.afterSelectedCountry = function (selected) {
        if (selected) {
            $scope.SelectedCountry = selected.originalObject;
        }
    }
    //Populate data from database 
    $http({
        method: 'GET',
        url:'/home/GetCountries'
    }).then(function (data) {
        $scope.Countries = data.data;
    }, function () {
        alert('Error');
    })
}]);
Posted By :