【发布时间】:2018-06-13 14:14:55
【问题描述】:
我需要帮助,我在 Ioni 3 中遇到管道问题,我一直在关注此线程 Ionic 3 cant find Pipe 和此链接 Ionic 3 Pipe Globally 但仍然没有运气,我得到的只是管道分隔符不起作用,我正在使用 ionic g 管道分隔符生成我的管道 我在我的 html 中使用我的管道
{{string | separator}}
我的 separator.ts(自定义管道)
import { Pipe, PipeTransform } from '@angular/core';
/**
* Generated class for the SeparatorPipe pipe.
*
* See https://angular.io/api/core/Pipe for more info on Angular Pipes.
*/
@Pipe({
name: 'separator',
})
export class SeparatorPipe implements PipeTransform {
/**
* Takes a value and makes it lowercase.
*/
transform(value: string, ...args) {
return value.toLowerCase();
}
}
我的 pipe.module.ts
import { NgModule } from '@angular/core';
import { SeparatorPipe } from './separator/separator';
@NgModule({
declarations: [SeparatorPipe],
imports: [],
exports: [SeparatorPipe]
})
export class PipesModule {}
我的 page.module.ts
import { NgModule } from '@angular/core';
import { IonicPageModule } from 'ionic-angular';
import { InfaqPage } from './infaq';
import { PipesModule } from '../../pipes/pipes.module';
@NgModule({
declarations: [
InfaqPage,
],
imports: [
IonicPageModule.forChild(InfaqPage),
PipesModule
],
})
export class InfaqPageModule {}
知道为什么它不起作用吗??
【问题讨论】:
-
您真的需要管道和页面的模块文件吗?
-
@pareshGami 我只是按照我提供的两个链接的说明,我必须使用模块文件作为管道,但仍然没有运气找不到在 ionic 3 中调用自定义管道的方法
标签: typescript ionic-framework ionic3