hit tracker

Usage of md-autocomplete in Angular Material

Home » Blog » UI » AngularJS » Usage of md-autocomplete in Angular Material

AngularJS is one of the most popular Client side Java Script languages today and there are many reasons for this. It has many qualities that make it suitable for development for users at most all levels. Let’s discuss how efficiently use the md-autocomplete in Angular Material.

Angular Material md-autocomplete introduces a special input component with a drop-down of all possible matches to a custom query. This component allows us to provide real-time suggestions as the user types in the input area.

md-autocomplete may get the input source via local object or from remote data source. Both are having different paradigms for consuming Suggestion data.

Core Features of md-autocomplete

Let us see the basic syntax of md-autocomplete


All the attributes of md-autocomplete is briefly explained in the Angular Material website https://material.angularjs.org/latest/api/directive/mdAutocomplete



Consider the Data is from Local as like below


Now see how the AngularJS should be for a Local Data


Consider the Data is from Remote from the sample URL  https://www.example.com/sample.aspx?token=one


Now see how the AngularJS should be for a Remote Data



In Remote Data, we should prefer .then instead of .success

  • .then() – full power of the promise API but slightly more verbose
  • .success() – doesn’t return a promise but offers slightly more convenient syntax

.then() – the $http API is based on the deferred/promise APIs exposed by the $q service, so it returns a promise for us by default.

Advance Features of md-autocomplete

Item Not Found:



How to set Minimum Length of Search Text:


How to set Cache Mode Enabled:


The Complete Source Code of HTML with AngularJS

The above Source Code is for Local Data Source, if you need a source code for a Remote Data Source kindly replace the <script> block to the specified Remote <script> block, which is briefly explained in the above.  


This article targets at understanding md-autocomplete programmatically using AngularJS especially for Remote Data Source. This article is intended for the beginner/intermediate level. I hope, this post will solve all your basic functionality implementation of md-autocomplete TextBox of Angular Material. Think Big… Start Small… Do Fast…

in AngularJS, UI by Balamanigandan B Comments are off
About the author: Balamanigandan B

Balamanigandan is a Software Engineer working at IncRev Corporation. He specializes in Programming languages like C#, PHP and Server Side Services like WCF, REST and UI Technologies like WPF, AngularJS.