Error: Ionic 3 is unable to locate the specified pipe

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 }}

Answer №1

Upon creating a tube through the CLI command

ionic generate tube HoursMinutesSeconds
, a shared module named tubes.module.ts will be generated. It is necessary to incorporate the TubesModule module in your page's module file.

Assuming the page is named my-view;

my-view.module.ts


import { NgModule } from '@angular/core';
import { IonicPageModule } from 'ionic-angular';
import { MyViewPage } from './my-view';
import { TubesModule } from '../../pipes/tubes.module';//<--- here

@NgModule({
  declarations: [
    MyViewPage,
  ],
  imports: [
    IonicPageModule.forChild(BudgetGroupViewPage),
    TubesModule // <--- here
  ],
})
export class MyViewPageModule { } 

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Using Jasmine to simulate an if/else statement in Angular/Typescript unit testing

After making a minor change to an existing function, it has been flagged as new code during our quality checks. This means I need to create a unit test specifically for the new 4 lines of code. The challenge is that there was never a unit test in place for ...

Issue in Angular: Attempting to access properties of undefined (specifically 'CustomHeaderComponent')

I have encountered a persistent error message while working on a new component for my project. Despite double-checking the injection code and ensuring that the module and component export logic are correct, I am unable to pinpoint the issue. custom-header ...

Incorporate a dropdown selection option into a clickable Angular 6 table row using Bootstrap 4 styling

I am currently updating a financial account book that displays all available accounts in a table format. Each row provides essential details about a specific account, and when a user clicks on a row, Angular redirects them to a detailed view for that parti ...

Retrieve an enumeration from a value within an enumeration

In my coding project, I have an enum called Animals and I've been working on a function that should return the value as an enum if it is valid. enum Animals { WOLF = 'wolf', BADGER = 'badger', CAT = 'cat', } cons ...

Using ES modules with TypeScript, Webpack, and Jasmine: A comprehensive guide

My Package Workflow For my personal projects, I have a consistent structure for the packages I create and reuse. In production, I write these packages in TypeScript and compile them to JavaScript using `tsc` before publishing them to npm. This allows me t ...

What is the most efficient way to iterate through an array to push properties into an object nested within another array?

I have been working on a small Angular application that functions as a scheduler, allowing users to input a Name, Start and End dates, and toggle a boolean checkbox through a form. One challenge I am facing is trying to assign the names entered by each use ...

Angular's use of observable async within an if statement allows for dynamic

After attempting the following code, I found that it was not functioning properly this.users$ = this.userService.get(); <span *ngIf="!users$ | async">No data</span> ...

Issue encountered with the signature provided for a Safe API POST request

Watch this demonstration video of the issue at hand: I have created a signer using my Metamask Private Key and generated a signature from it as shown below: const signer = new ethers.Wallet(PRIVATE_KEY as string, provider) const safeInstance = new ethers. ...

Tips for avoiding the push method from replacing my items within an array?

Currently, I am diving into Typescript and VueJS, where I encountered an issue with pushing elements to my array. It seems to constantly override the 'name' property. Let me share the code snippet causing this problem: const itemsSelectedOptions ...

Navigate to a different HTML file following a JavaScript function in Ionic and AngularJS with Cordova

I am currently creating an Android application in Cordova Tools for Visual Studio using Ionic and AngularJS. My goal is to redirect to another HTML page once my function has completed its execution, but I'm having trouble getting it to work correctly ...

Single array returned by observable

Issue: I am looking for a way to consolidate the multiple arrays returned individually into a single array. Solution: fetchAllRiders() { var distanceObs = Observable.create(observer => { this.http.get(this.API + '/driver/all').map(res = ...

The continuity of service value across parent and child components is not guaranteed

My goal is to update a value in a service from one component and retrieve it in another. The structure of my components is as follows: parent => child => grandchild When I modify the service value in the first child component, the parent receives t ...

What is the best method for retrieving an element's key in Firebase using AngularFire2?

In my Angular project, I have a table displaying products. Everything looks good except for the link format /admin/products/key that is not working. It seems like p.$key is not showing the key value: <table class="table"> <thead> ...

Tips for guaranteeing a Typescript string enum with identical key and value pairs

I am looking for a way to create a generic type that verifies certain criteria on an enum: all fields must be strings all values must be equal to their respective keys For example, the following enums would meet the requirements: enum correct1 { bar ...

Angular 5 authentication token validation

I'm feeling a bit lost when it comes to creating a proper header for a simple Get request in Angular 5. Here is what I'm trying to achieve in Angular: https://i.sstatic.net/53XMi.png This is my current progress: getUserList(): Observable&l ...

Is there a way to track the frequency of the retry operator running in case an error exception occurs?

@Injectable() export class ErrorInterceptor implements HttpInterceptor { constructor() { } intercept(request: HttpRequest<any>, next: HttpHandler): Observable<HttpEvent<any>> { return next.handle(request) .pip ...

The RemoveAt(i) function will not eliminate

I am facing an issue with the removeAt(i) function in my code. It is not removing the element at the specified index. Can someone guide me on how to properly remove an element from an array? Here is the StackBlitz link for reference HTML <form [formGro ...

An issue was encountered when attempting to log out the user from Firebase

My website is built using the Ionic and Angular Frameworks along with Firestore database. The signout feature works as expected, but unfortunately, an error occurs when a user tries to sign out of their account. The error message: FirebaseError: Missing o ...

How come my pipelining implementation in C programming is not producing the concatenated string as expected?

I am currently experimenting with a C programming example I found online that illustrates the concept of pipelining using pipe() and fork(). The program is designed to concatenate an input string with a predefined string within the code. Although the cod ...

Angular 2 - Component's Off-click Feature Falters

Achieving a desired effect using Angular 2, I have implemented a component with a small popup <div>. The popup is dismissed when the user clicks anywhere on the document except for the popup itself. To achieve this functionality, I utilize HostListen ...