Introduction
Searching through large data sets often can be a difficult and time consuming task. Fortunately, ngx-mat-select-search is a library that can help improve search performance when using the angular Material Design library’s mat-select component. ngx-mat-select-search provides an efficient way to filter through large lists of data that can be used for improved search results.
Prerequisites
- An understanding of angular Material Design’s mat-select component
- Node.js 8.x or higher installed
- Angular CLI 8.x or higher
Step-by-Step Guide
- Install the ngx-mat-select-search library from NPM:
npm install ngx-mat-select-search
- Import
MatSelectSearchModule
inapp.module.ts
:
import {MatSelectSearchModule} from 'ngx-mat-select-search';
@NgModule({
imports: [
MatSelectSearchModule,
...
],
...
})
export class AppModule { }
- Use
mat-select-search
in your template:
<mat-form-field>
<mat-select [(value)]="selectedValue" #singleSelect>
<mat-option *ngFor="let item of items" [value]="item.value">
{{item.name}}
</mat-option>
</mat-select>
<mat-select-search [formControl]="singleSelect.ngControl"></mat-select-search>
</mat-form-field>
- Include an input for the
mat-select-search
:
<input *ngIf="singleSelect.panelOpen" matInput [formControl]="singleSelect.ngControl" [matAutocomplete]="auto" class="search" placeholder="Type here to search...">
FAQ
Q: Does ngx-mat-select-search require any additional libraries?
A: No, ngx-mat-select-search is independent and does not require any additional libraries.
Q: Does ngx-mat-select-search work on iOS?
A: Yes, ngx-mat-select-search is compatible with iOS devices.