Avdhut
Avdhut

Reputation: 85

How i can add Search Functionality in angular material select form component?

I have mat-select Drop-down from angular material.
It has list of state which is coming from API. It has more than 10 options in Drop-down.

Todo :

Please suggest me simple way to do it.

My json code

"{
  "data": [
    {
      "id": 32,
      "name": "Andaman And Nicobar Islands"
    },
    {
      "id": 16,
      "name": "Odisha"
    },
    {
      "id": 34,
      "name": "Puducherry"
    },
    {
      "id": 19,
      "name": "Uttar Pradesh"
    },
    {
      "id": 5,
      "name": "Uttarakhand"
    },
    {
      "id": 6,
      "name": "Andhra Pradesh"
    }
  ],
  "statusCode": 200
}"

Upvotes: 1

Views: 352

Answers (1)

Seba Cherian
Seba Cherian

Reputation: 1793

<mat-select-search [formControl]="formControlName"></mat-select-search>

Add this tag inside mat-select and follow the steps in app.component.ts of StackBlitz

Upvotes: 6

Related Questions