无法识别角度导入管道



我正在尝试在我的个人培训项目中使用以下管道,按照规范,我已经使用 npm 安装了库,我可以在 ng 模块文件夹中看到它

然后我尝试在我的app.module中添加NgPipesModule,如下所示

import {NgPipesModule} from 'ngx-pipes';

@NgModule({
imports: [
BrowserModule,
BoxingSharedModule,
BoxingCoreModule,
BoxingHomeModule,
NgPipesModule,
// jhipster-needle-angular-add-module JHipster will add new module here
BoxingEntityModule,
BoxingAppRoutingModule
],
declarations: [JhiMainComponent, NavbarComponent, ErrorComponent, PageRibbonComponent, ActiveMenuDirective, FooterComponent],
providers: [
{

因为我相信这应该足以使用filterBy管道!!

所以这是我使用它所做的

<tr *ngFor="let boxer of boxers | filterBy: [searchFilter]: searchValue.value ;trackBy: trackId">

过滤器值由以下提供:

<input type="text" class="form-control" placeholder="Search"
aria-label="Search" aria-describedby="basic-addon2" #searchValue>
<div class="input-group-append" (click)="onButtonGroupClick($event)">
<button class="btn btn btn-outline-primary" type="button" value="fullName">FullName</button>
<button class="btn btn btn-outline-primary" type="button" value="phone">Phone Number</button>
<button class="btn btn btn-outline-primary" type="button" value="birthDate">Birth Date</button>
</div>

浏览器控制台日志显示没有解决管道,如下所示:

错误

错误: 未捕获 (在承诺中(: 错误: 模板解析错误: 找不到管道"filterBy"("1(" [无限滚动禁用]="页面>= links['last']" [无限滚动距离]="0"> 拳击手的oxer |filterBy: [searchFilter]: searchValue.value ;trackBy: trackId"> = links['last']" [无限滚动距离]="0"> ]拳击手的oxer |filterBy: [searchFilter]: searchValue.value ;trackBy: trackId">

我不知道我在这里错过了什么?

你应该知道我正在使用JHipster

您的配置是正确的,但我不确定您的组件位置。

要让您的组件使用该管道,您还需要将该组件添加到declarations数组中。要使用管道的组件必须位于导入管道的同一模块中

最新更新