hit tracker

Angular material

Home » Angular material

Usage of md-autocomplete in Angular Material

in AngularJS, UI by Balamanigandan B Comments are off

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…

Floating label support for md-chips in AngularJS

in AngularJS, UI by Selva Kumar Comments are off

The Angular Material has already become popular and seems to gain a great acceptance worldwide as a general design guideline among the Web. It provides a set of reusable, well-tested, and accessible UI components based on the Material Design system.


Inconsistent UI for md-input fields & md-chips with md-autocomplete

For md-input & md-autocomplete the form fields have floating label (i.e. when the user focuses the  textbox or autocomplete the label jumps to top & provides space for entering values ) whereas the md-chips control not providing the floating label option, it just clears the label value and you can type in your values.






To provide the consistent UI effect, here we are going to customize the md-chips with md-autocomplete control. In md-autocomplete control instead of placeholder property we are going to use md-floating-label property.

By using md-floating-label with md-autocomplete we will be able to get the floating label, but the problem is with selected item styles & some padding effects.



We can fix these issues by customizing the angular-material.css

Hurray!! We have done it. Hopefully this feature will be added to md-chips control in near future.

You can download the sample project from the github.