【发布时间】:2017-01-12 05:45:37
【问题描述】:
我有一个管道
@Pipe({name: 'keys'})
export class KeysPipe implements PipeTransform {
transform(value, args:string[]) : any {
.....
return keys;
}
}
我有两个模块需要使用它。如果我在两个模块中都这样做,我会收到一条错误消息,说“两个模块声明 KeysPipe”
模块1、模块2:
declarations: [KeysPipe],
然后我尝试通过它自己的模块导出 KeysPipe,以便我可以将它导入到我需要使用它的两个模块中
@NgModule({
declarations: [ KeysPipe],
})
export class KeysPipeModule {
}
现在我在需要使用 KeysPipe 的两个模块中导入 KeysPipeModule
模块1、模块2:
imports: [KeysPipeModule],
但现在我收到一个不同的模板错误,提示找不到管道“找不到管道'键'(“v *ngIf="docalc">”
【问题讨论】:
标签: javascript angular typescript pipe