Angular 10 Auto-Complete Example

Angular 10 Auto-Complete Example

In this post we will give you information about Angular 10 Auto-Complete Example. Hear we will give you detail about Angular 10 Auto-Complete ExampleAnd how to use it also give you demo for it if it is necessary.

In this example, we’ll learn how to build an Angular 10 auto complete example.

We’ll need to have a few prerequisites for this tutorial such as Node.js and Angular CLI v10 installed on our local development machine.

Next, you’ll need to create a project using the following command:

$ ng new Angular10AutoCompleteExample

The CLI will ask you a couple of questions — If Would you like to add Angular routing? Type y for Yes and Which stylesheet format would you like to use? Choose CSS.

Installing Angular-Ng-Autocomplete

Next, you’ll need to navigate to your project’s folder and install the angular-ng-autocomplete library:

$ cd Angular10AutoCompleteExample$ npm install angular-ng-autocomplete

Importing the AutocompleteLibModule

Next, open the src/app/app.module.ts file and import AutocompleteLibModule and add it in the imports array”


That’s it, you can now use angular-ng-autocomplete in your components.

Adding Auto Complete Feature to our Angular 10 App

Open the src/app/app.component.ts file and update it as follows:

import{Component}from'@angular/core';@Component({selector:'my-app',templateUrl:'./app.component.html',styleUrls:['./app.component.css']})exportclassAppComponent{keyword='name';publiccountries=[{id:1,name:'Albania',},{id:2,name:'Belgium',},{id:3,name:'Denmark',},{id:4,name:'Montenegro',},{id:5,name:'Turkey',},{id:6,name:'Ukraine',},{id:7,name:'Macedonia',},{id:8,name:'Slovenia',},{id:9,name:'Georgia',},{id:10,name:'India',},{id:11,name:'Russia',},{id:12,name:'Switzerland',}];selectEvent(item){// do something with selected item}}

Next. open the src/app/app.component.html file and update it as follows:

<divclass="ng-autocomplete"><ng-autocomplete[data]="countries"[searchKeyword]="keyword"placeHolder="Enter the Country Name"(selected)='selectEvent($event)'(inputChanged)='onChangeSearch($event)'(inputFocused)='onFocused($event)'historyIdentifier="countries"[itemTemplate]="itemTemplate"[notFoundTemplate]="notFoundTemplate"></ng-autocomplete><ng-template#itemTemplatelet-item><a[innerHTML]=""></a></ng-template><ng-template#notFoundTemplatelet-notFound><div[innerHTML]="notFound"></div></ng-template></div>

Finally, we can some CSS code for styling the auto complete component. Open the src/app/app.component.css file and update it as follows:


Check the docs for more information.


In this example, we’ve seen how to implement the auto complete feature in our Angular 10 app using angular-ng-autocomplete.

Hope this code and post will helped you for implement Angular 10 Auto-Complete Example. if you need any help or any feedback give it in comment section or you have good idea about this post you can give it comment section. Your comment will help us for help you more and improve us. we will give you this type of more interesting post in featured also so, For more interesting post and code Keep reading our blogs

For More Info See :: laravel And github

We're accepting well-written guest posts and this is a great opportunity to collaborate : Contact US