A critical error has occurred: RangeError - The maximum call stack size has been exceeded while trying to

After attempting to filter a list of titles using Ng2SearchPipeModule, I imported the module in app.module.ts and created a new searchbar component.

searchbar.component.ts

import { FirebaseService } from './../../firebase.service';
import { AngularFirestore } from '@angular/fire/firestore';
import { Component, OnInit} from '@angular/core';

@Component({
  selector: 'app-searchbar',
  templateUrl: './searchbar.component.html',
  styleUrls: ['./searchbar.component.css']
})

export class SearchbarComponent implements OnInit{
constructor(private fireService:FirebaseService){}

titles:Array<any>;
  InputText:string;
  ngOnInit(){
    this.gettitles();
  }

  gettitles(){
    this.fireService.read_titles().subscribe(result =>{
      this.titles = result;
      console.log(this.titles);
    })
  }
}

My searchbar.component.html contains the following code

  <div class="search-field">
    <mat-form-field>
      <mat-label>Search</mat-label>
      <input id="input" type="text" matInput placeholder="" autocomplete="off" [(ngModel)]=InputText>
      <div><i class="fas fa-search"></i></div>
    </mat-form-field>
  </div>

  <div class="SearchTitles">
    <tbody>
      <tr *ngFor="let title of titles | filter:InputText">
        <td>{{title.payload.doc.data().title}}</td>
      </tr>
    </tbody>
  </div>

Although I am receiving the correct output from Firebase Firestore, I am encountering an error each time I type a character into the input field, and the filtering is not happening.

This error seems to be related to the filter module. I have been unable to find any information on how to resolve this issue...

Thank you for your assistance

Answer №1

It seems like the issue lies in the format of your titles not being an array of strings. You can resolve this by adjusting the title array to be an array of strings:

The service function should be modified to return the actual titles:

SERVICE

constructor(private afs: AngularFirestore) { }

read_titles() {
    return this.afs.collection<{title: string}>('here-your-table').valueChanges().pipe(
        map(list => list.map(v => v.title))
    )
}

Your component's TypeScript code should look like this:

gettitles(){
    this.fireService.read_titles()
}

Lastly, in your HTML file, make sure to update the following code:

<tr *ngFor="let title of titles | async | filter:InputText">
    <td>{{title}}</td>
</tr>

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

What is the best way to set an array as the value for a state variable?

Looking at my function, I have the following situation: execute(e) { let { items } = this.context; let array: number[] = []; for (var i = 0; i < 2; i++) array = [...array, i]; this.setState( { items: array, } ) ...

Unable to attach to 'leafletOptions' as it is unrecognized as a property of 'div'

It seems like I keep encountering this problem, which is often resolved by adjusting import statements. Right now, my imports look like this: import { LeafletModule } from 'node_modules/@asymmetrik/ngx-leaflet'; import * as L from 'leaflet& ...

How can I determine the data type of an Array element contained within an Interface member?

Is there a way to extract the type of key3 in MyInterface2 and use it in key3Value, similar to key2Value? interface MyInterface { key1: { key2: string } } const key2Value: MyInterface['key1']['key2'] = 'Hi' / ...

Retrieve the value of a promise and transfer it to the subsequent function of an observable

For my Angular 9 application, I have created a custom interceptor called AuthorizationHeaderInterceptor: @Injectable() export class AuthorizationHeaderInterceptor implements HttpInterceptor { constructor(private authenticationService: AuthenticationSer ...

Implementing Authorization Headers in Angular for Secure HTTP Post Requests

I have been struggling to add Authorization Headers to a Post request after extensive research and trying various ways of adding headers to the request. I need to authenticate the post request of my Angular app to a Django server. headers2 = { "Conte ...

Angular 8: ISSUE TypeError: Unable to access the 'invalid' property of an undefined variable

Can someone please explain the meaning of this error message? I'm new to Angular and currently using Angular 8. This error is appearing on my console. ERROR TypeError: Cannot read property 'invalid' of undefined at Object.eval [as updat ...

Tips for upgrading from AngularJS 1.8.x to Angular CLI version 11.2.3

Looking for a straightforward way to update the angular version for my web app. Any suggestions on how to go about this? ...

Is the Angular Library tslib peer dependency necessary for library publication?

I have developed a library that does not directly import anything from tslib. Check out the library here Do we really need to maintain this peer dependency? If not, how can we remove it when generating the library build? I have also posted this question ...

Unit Testing Sentry with Jest Framework using TypeScript in a Node.js Environment

I'm in the process of integrating Sentry into my existing NodeJS project, but I'm facing an issue with mocking a specific part of the Sentry code. Here's the relevant Sentry code snippet: const app: express.Express = express(); Sentry.init ...

Enhance your data presentation with Angular Material tables featuring multiple sources

I am currently facing an issue with my table that is being used to display multiple sets of data. The problem I'm encountering is that while the data is showing up correctly, the paginator and sort functions are not working as intended. The sorting ...

What steps can I take to concentrate on a particular mat-tab?

<mat-tab-group mat-stretch-tabs #tabGroup (focusChange)="tabChanged($event)" [selectedIndex]="0"> <mat-tab label="DATOS EXPEDIENTE"> <div class="example-large-box mat-elevation-z4"> <app-informe-expediente></app ...

Encountered an issue launching the advanced web server and reverse proxy server nginx for high performance

UPDATE - Recently, I encountered the following error logs: nginx: [emerg] unknown "request_url" variable Aug 19 01:14:58 nginx[4890]: nginx: configuration file /etc/nginx/nginx.conf test failed Below is my nginx.conf file: user www-data; worker ...

Unraveling the complexities of Typescript's Advanced Type NonFunctionPropertyNames

Delving deeper into the realm of advanced types in Typescript, I came across an intriguing type called NonFunctionPropertyNames. This type is designed to extract only the properties of a given object that are not functions. type NonFunctionPropertyNames&l ...

When I specify the type for the function parameter, an error occurs when I attempt to execute the function

When I assign a generic type to the function parameter and try to call the function, an error message pops up stating "This expression is not callable. Type unknown has no call signature." function a() { return 'abc' } function fun<T>(x: T ...

Navigating horizontally to find a particular element

I developed a unique Angular component resembling a tree structure. The design includes multiple branches and nodes in alternating colors, with the selected node marked by a blue dot. https://i.stack.imgur.com/fChWu.png Key features to note: The tree&ap ...

Once the Ionic platform is prepared, retrieve from the Angular factory

I have created a firebase Auth factory that looks like this: app.factory("Auth", ["$firebaseAuth", "FIREBASE_URL","$ionicPlatform", function($firebaseAuth, FIREBASE_URL, $ionicPlatform) { var auth = {}; $ionicPlatform.ready(function(){ ...

What is the best way to define the starting page in the infinite row model?

As I work with Ag-Grid version 20.0.0 using the Infinite row model and enabled pagination features, I am trying to set the initial page for the first load. However, I have not found any property that would allow me to customize this aspect. The only meth ...

Challenges Experienced by AoT in Live Operations

So in my project, I have various components and services included where necessary. To ensure their accessibility, I made sure to declare all the services as private within the constructor. Here's an example: constructor(private myService: MyService) ...

Tips for troubleshooting errors such as "Maximum call stack size exceeded"

I've been working on an Ionic/angular project that I paused for a while. When I resumed working on it, I encountered an error in the console. The unusual effect is that nothing is displayed for 10-15 seconds, then my app loads, but I don't notice ...

What is the best way to create a props interface that includes state and setState values that are being

As I dive deeper into TypeScript, a hurdle has appeared in my app. Upon introducing React.FunctionComponent to my components, an issue arose with my Props interface. The error message reads: Type '({ value, setValue, }: Props) => JSX.Element' ...