Angularjs – How To Create Autocomplete on an Input Field?

Today, We want to share with you autocomplete textbox in angularjs.In this post we will show you how to get selected value from autocomplete textbox in angularjs, hear for Implement Autocomplete textbox using AngularJS from database we will give you demo and example for implement.In this post, we will learn about AngularJS Search Auto Suggestion box with PHP MySQLi with an example.

Autocomplete in angularjs

here we can learn to How to create a facebook style autocomplete using Angularjs?

step 1: index.html

  
  
 

step 2: $ajax at your app.js file

 var app = angular.module('pakainfoApplication', ['ui.bootstrap']);
    app.controller('autocompleteController', function($scope, $http) {  
        getProducts(); // Load all products with categorys  
        function getProducts(){  
            $http.get('ajax/getProducts.php').success(function(data){  
                $scope.products = data;  
            });  
        };  
    });

autocomplete.html

  

Bind the typeahead directive

  

getProducts.php


query($query) or die($mysqli->error.__LINE__);

$arr = array();  
    if($result->num_rows > 0) {  
    while($row = $result->fetch_assoc()) {  
    $arr[] = $row;  
    }  
    }

# JSON-encode the response  
echo $json_response = json_encode($arr);  
?>  

I hope you get an idea about Auto Complete Text box in Angular.JS with Dynamic Data using Web API.
I would like to have feedback on my infinityknow.com blog.
Your valuable feedback, question, or comments about this article are always welcome.
If you enjoyed and liked this post, don’t forget to share.

Leave a Comment