错误:模板解析错误:在角度中找不到管道“过滤器" [英] Error: Template parse errors: The pipe 'filter' could not be found in angular

查看:22
本文介绍了错误:模板解析错误:在角度中找不到管道“过滤器"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

导入此过滤器

// search module
import { Ng2SearchPipeModule } from 'ng2-search-filter';

它的 HTML 代码

//search

<input class="form-control" type="text" name="search" [(ngModel)]="searchText" autocomplete="off" placeholder="search">

//Assigned filter to table

 <tr *ngFor="let bookName of NameOfBookList | filter:searchText">

任何帮助将不胜感激.

推荐答案

仅将 Ng2SearchPipeModule 添加到对我有用的导入中.添加到声明时,我的浏览器工具中出现错误,指出 Ng2SearchPipeModule 有意外声明.

Adding Ng2SearchPipeModule ONLY to the imports worked for me. When adding to the declarations I got an error in my browser tools stating that there was an unexpected delcaration for Ng2SearchPipeModule.

@NgModule({
declarations: [
    AppComponent,
    ListComponent
],
imports: [
    BrowserModule,
    FormsModule,
    Ng2SearchPipeModule
],
providers: [],
bootstrap: [AppComponent]
})

然后在我的标记中:

<input [(ngModel)]="term">
...
<tbody *ngFor="let d of myList |filter:term">

这篇关于错误:模板解析错误:在角度中找不到管道“过滤器"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆