Show refined information upon form submission or click

I am facing a challenge with implementing filtering functionality in an input box within a form in Angular 12. Despite my efforts, I have been unable to get the pipe working correctly in the component and consequently in the view.

HTML

                       <form #form="ngForm" >
                          <div class="form--inline clearfix d-flex">
                             <div class="form-item">
                                <label for="edit-combine">Search Reports</label>
                                <div class="inner-addon left-addon" style="position: relative">
                                   <i class="bi bi-search" style="position: absolute; padding: 5px; pointer-events: none; font-size: 1rem"></i>
                                   <input style="padding-left: 30px" placeholder="Search" type="text" id="edit-combine" name="combine" value="" size="30" maxlength="128" class="form-text form-control" [(ngModel)]="titleList">
                                </div>
                             </div>
                             <div id="edit-actions">
                                <input type="submit" class="button" (click)="onSubmit()" id="edit-submit-buscador-de-informes" value="">
                             </div>
                             <div *ngFor="let flex of informesTitle">
                                {{flex}}
                              </div>
                          </div>
                       </form>

TS Component

import { Component, OnInit } from '@angular/core';
import { NgForm } from '@angular/forms';
import { FlexSlider, FrontService, InformesCounter } from './front.service';

import { FrontPipe } from './front.pipe';

@Component({
  selector: 'app-front',
  templateUrl: './front.component.html',
  providers: [ FrontService, FrontPipe ],
    styleUrls: ['./front.component.sass']
})
export class FrontComponent implements OnInit {
  error: any;
  ...

  showInformes() {
      ...
        this.filteredText = new FrontPipe().transform(this.titleList);
        
      });  
  }

  onSubmit(){
    console.log(this.filteredText)
  }

TS PIPE

import { Pipe, PipeTransform } from '@angular/core';

@Pipe({
  name: 'front'
})
export class FrontPipe implements PipeTransform {
  transform(items: any): any {
      ...
    
  }
  
}

Despite my best efforts, I have been unable to successfully integrate the pipe into the component that receives JSON data from a service in order to filter results. Any assistance is greatly appreciated. Thank you.

Answer №1

CORRECTED

I had overlooked passing the Pipe arguments to the function and including them in the onSubmit Function.

onSubmit(){
this.filteredText = new CustomPipe().transform(this.titleList, this.searchText);
console.log(this.filteredText)
}

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

Navigating directly to URLs in Angular Universal with iisnode

My issue involves an Angular Universal application. While everything runs smoothly locally with express, and inside of node, deploying the production build to IIS with iisnode results in a 500 Internal Server Error when navigating directly via URL. Unfor ...

Setting a value to an optional property of an inherited type is a simple task that can

export interface CgiConfiguration { name: string, value?: string } export interface CgiConfigurationsMap { [configurationName: string]: CgiConfiguration } const createCGI = <T extends CgiConfigurationsMap>(configurations: T) => configur ...

The error message "TranslateService not found" seems to be linked to the npm installation process

Encountering an issue with my Angular+Webpack+JHipster+yarn project where a particular error keeps reappearing despite deleting `node_modules` and running 'npm install`. The error seems to be related to the TranslateService provided by a library, not ...

What is the reason for TestBed using waitForAsync in beforeEach instead of directly using async/await to compileComponents?

UPDATE: I submitted a problem report to Angular and they have since made changes to the documentation: https://github.com/angular/angular/issues/39740 When working on Angular tests, it is common practice to set up the beforeEach method like this: befo ...

Creating dynamic checkboxes and dropdown menus in Angular 8 by fetching data from an API

Take a look at my Stack Blitz project: here I am trying to achieve two things: hide the dropdown if the divisions are empty, and set the default value of the dropdown to the first one in the list. Can anyone guide me on how to accomplish this? Your help ...

When using NextJS <Link, mobile users may need to tap twice to navigate

Whenever I use the NextJS <Link tag on my mobile device, I notice that I have to double-tap for the link to actually route to the desired page. Take a look at the code snippet below: <Link href="/methodology" passHref={true} ...

Tips on refreshing asset information within a live Angular application

I am currently managing an Angular project on a web server. The server houses python scripts that run periodically to generate a .json file. This latest version of the .json file replaces the existing one in the assets folder of the project (dist/test/asse ...

State mutation not reflected in input field value update

During the development of a small project for educational purposes, I encountered an issue with updating the input value. Below is the simplified component causing this issue. function TipSelector({selections, onTipChanged}: {selections: TipSelectorItem[], ...

An effective method for excluding null values with an Angular pipe

I am currently working on an Angular pipe that filters results based on user input. The problem I'm encountering is that some of the results do not have a value, resulting in this error message: Cannot read property 'toLocaleLowerCase' o ...

The concealed [hidden] attribute in Angular2 triggers the display of the element after a brief delay

I am currently utilizing the [hidden] attribute within my application to conceal certain elements based on a specific condition. The situation is such that I have two divs - one for displaying results and another for showing the text "No results". Both t ...

Unable to connect input with abstract classes at a hierarchy depth of 2 levels or more

When working on my Angular application: If a Component utilizes an Input that is defined in its immediate parent (abstract) class, everything runs smoothly. However, if a Component uses an Input that is declared in a parent class located two levels a ...

Sending the route path to the child component

<Route path="/pointandclick"> <MyComponent /> </Route> Is there a way for MyComponent to retrieve the path of the Route that was accessed in the code above? To clarify, if I want to determine the specific ...

Is there a way to sort through an array based on a nested value?

Within an array of objects, I have a structure like this: "times": [{ "id" : "id", "name" : "place", "location" : "place", "hours" : [ {"day": " ...

The issue of excessive recursion in Typescript

Currently, I am in the process of learning Typescript while working on some exercises. While attempting to solve a particular problem, I encountered an error related to excessive recursion. This issue arises even though I created wrapper functions. About ...

The function e.preventDefault() appears to be ineffective when applied to both the submit button and anchor tag within an

In my ASP.Net Core MVC App View <form> <div class="container"> <div class="row"> <div class="col-md-offset-2 col-md-4"> <div class="form-group"> <input type="text" class="form-contr ...

Choose a specific interface in Typescript

I am interested in developing a React alert component that can be customized with different message colors based on a specific prop. For example, I envision the component as <alert id="component" info/> or <alert id="component" ...

Encountering a 404 (Not Found) error while trying to access a null resource in Angular at http://localhost

Currently, I am developing an angular application with ng9. I have a specific div where I need to display an avatar using an image fetched from the API in my component.ts file: .... export class HomeComponent implements OnInit { nextLaunch$: Observabl ...

significant issue arising from slow input box typing in angular 5 causing concern

We've encountered a troublesome issue that is hindering our progress despite completing a web app using angular 5 & template driven forms. Everything works flawlessly except for one feature causing major disruption, like a sniper shot hitting us unexp ...

Parsing temporary storage of database query results

My experience with OOP languages like C# and Java has been good, but I am relatively new to JavaScript/TypeScript. I find callback functions confusing, especially when using them with the BaaS ParseDB. For example, finding all playlists for a certain user ...

Exploring ways to send data to WebView in Flutter

How can I pass the location obtained in my Flutter app to a WebView for further processing within the opened site? var userLocation = Provider.of<UserLocation>(context); Here is my WebView setup: WebView( initialUrl: widget.url, javasc ...