【发布时间】:2017-09-04 02:33:39
【问题描述】:
我刚刚升级到Ionic 3.0.1,所以我可以使用LazyLoading,因此我不能使用我的自定义Pipes:
import { Pipe, PipeTransform } from '@angular/core';
@Pipe({
name: 'StripHTML'
})
export class StripHTML implements PipeTransform {
transform(value, args) {
let striped = value.replace(/(<([^>]+)>)/g, "");
if (args != null) {
if (args.split != null) {
striped = striped.split(args.split);
if (args.index != null) {
striped = striped[args.index];
}
}
}
return striped;
}
}
在app.module.ts 中,我已将其添加到声明中:
@NgModule({
declarations: [
........,
StripHTML
],
...
现在当我尝试在 html 模板中使用它时会出错:
core.es5.js:1085 ERROR Error: Uncaught (in promise): Error: Template parse errors:
The pipe 'StripHTML' could not be found ("
<ion-card-content>
<ion-card-title style="font-size: 100%">
{{ [ERROR ->]product.title | StripHTML }}
</ion-card-title>
</ion-card-content>
"): ng:///HomeModule/Home.html@33:17
这里有什么我遗漏的吗?
【问题讨论】:
-
自迁移以来我遇到了类似的错误:找不到名称“PipeTransform”
标签: angular typescript ionic-framework ionic3