0
votes

I'm trying to use the ngx-mat-select-search component. I followed the tutorial on https://www.npmjs.com/package/ngx-mat-select-search but after I install it and try to use the exact code from the tutorial (https://stackblitz.com/github/bithost-gmbh/ngx-mat-select-search-example) I always get this error when I try to use the ngx-mat-select-search tag (<ngx-mat-select-search></ngx-mat-select-search>):

'ngx-mat-select-search' is not a known element: 1. If 'ngx-mat-select-search' is an Angular component, then verify that it is part of this module. 2. If 'ngx-mat-select-search' is a Web Component then add 'CUSTOM_ELEMENTS_SCHEMA' to the '@NgModule.schemas' of this component to suppress this message.

Thank you for your help!

1
You need to either declare the component in your module or import the module from the npm package with exports itinorganik

1 Answers

2
votes

I'd definitely try the following steps.

Install ngx-mat-select-search in your project:

npm install ngx-mat-select-search

Import the NgxMatSelectSearchModule in your app.module.ts:

    import { MatFormFieldModule, MatSelectModule } from '@angular/material';
    import { NgxMatSelectSearchModule } from 'ngx-mat-select-search';

    @NgModule({
      imports: [
        ReactiveFormsModule,
        BrowserAnimationsModule,
        MatSelectModule,
        MatFormFieldModule,
        NgxMatSelectSearchModule
      ],
    })

export class AppModule {}

Use the ngx-mat-select-search component inside a mat-select element by placing it inside a element:

<mat-form-field>
  <mat-select [formControl]="bankCtrl" placeholder="Bank" #singleSelect>
    <mat-option>
      <ngx-mat-select-search [formControl]="bankFilterCtrl"></ngx-mat-select-search>
    </mat-option>
    <mat-option *ngFor="let bank of filteredBanks | async" [value]="bank">
      {{bank.name}}
    </mat-option>
  </mat-select>
</mat-form-field>