角度:'ngx-mat-select-search'不是已知元素



>我正在尝试使用 ngx-mat-select-search 组件。我按照 https://www.npmjs.com/package/ngx-mat-select-search 教程进行操作,但是在安装它并尝试使用教程(https://stackblitz.com/github/bithost-gmbh/ngx-mat-select-search-example(中的确切代码后,当我尝试使用ngx-mat-select-search标签(<ngx-mat-select-search></ngx-mat-select-search>(时,我总是收到此错误:

'ngx-mat-select-search' 不是一个已知的元素: 1. 如果 'ngx-mat-select-search' 是一个 Angular 组件,那么验证它是否是这个模块的一部分。 2. 如果"ngx-mat-select-search"是 Web 组件,则将"CUSTOM_ELEMENTS_SCHEMA"添加到该组件的"@NgModule.schemas"以禁止显示此消息。

感谢您的帮助!

我肯定会尝试以下步骤。

在你的项目中安装 ngx-mat-select-search:

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 {}

通过将 ngx-mat-select-search 组件放置在元素中,在 mat-select 元素内使用它:

<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>

最新更新