I am unable to locate any issues with this problem. I have already imported it in app.module.ts and included it in the 'declaration' section.
In app.module.ts
import { NgModule, ErrorHandler } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { IonicApp, IonicModule, IonicErrorHandler } from 'ionic-angular';
import { MyApp } from './app.component';
//ionic-native
import { NativeStorage } from '@ionic-native/native-storage';
import { StatusBar } from '@ionic-native/status-bar';
import { SplashScreen } from '@ionic-native/splash-screen';
//pipe
import { HoursMinutesSecondsPipe } from '../pipes/hours-minutes-seconds/hours-minutes-seconds';
@NgModule({
declarations: [
MyApp,
HoursMinutesSecondsPipe
],
imports: [
BrowserModule,
IonicModule.forRoot(MyApp, {
platforms: {
android: {
tabsPlacement: 'top'
}
}
}),
],
bootstrap: [IonicApp],
entryComponents: [
MyApp,
],
providers: [
StatusBar,
SplashScreen,
{provide: ErrorHandler, useClass: IonicErrorHandler},
NativeStorage,
]
})
export class AppModule {}
Usage:
<ion-card class="card-container" (click)="onTimer()">
<img src="assets/imgs/wp1.png"/>
<div class="card-title">Time Smoke Free</div>
<div class="card-subtitle">{{ seconds | hoursMinutesSeconds }}</div>
</ion-card>
In hours-minutes-seconds.ts
import { Pipe, PipeTransform } from '@angular/core';
@Pipe({
name: 'hoursMinutesSeconds',
})
export class HoursMinutesSecondsPipe implements PipeTransform {
transform(value, args?) {
let minutes = Math.floor(value / 60);
let hours = Math.floor(minutes / 60);
let seconds = Math.floor(value % 60);
let timeString = hours + 'hrs ' + minutes + 'mins ' + seconds + 'secs';
return timeString;
}
}
Error: Uncaught (in promise): Error: Template parse errors: The pipe 'hoursMinutesSeconds' could not be found ("imgs/wp1.png"/> Time Smoke Free {{ [ERROR ->]seconds | hoursMinutesSeconds }}