首页 > 解决方案 > 错误 --> 使用 angular4 时找不到管道“过滤器”

问题描述

我正在 angular4 -node.js 部署的项目中进行单元测试。在测试时我发现了这个错误 -

Template parse errors:
The pipe 'filter' could not be found ("
  </thead>
  <tbody>
    <tr *ngFor="let[ERROR ->] dat of result | filter:filterdata| 
paginate: { itemsPerPage: 5, currentPage: p };let i = index ">

所以我将这两个模块添加到我的 module.ts 和 spec.ts 文件中 -->

import { PipesModule } from '../../pipes/pipes.module';
import { Pipe, PipeTransform } from '@angular/core';

@NgModule({
 imports: [PipesModule
 ],

对于这个特定的模块导入 -->

import { PipesModule } from '../../pipes/pipes.module';

错误 --> 找不到模块 '../../pipes/pipes.module'。

请帮助解决问题

标签: angular

解决方案


您必须在 PipesModule 的声明和导出中包含 FilterPipe。


推荐阅读