An issue has occurred: The function _co.deleteConsulta is not recognized as a valid function

While following a tutorial on creating a CRUD application using Firestore, I encountered an issue when trying to delete data from Firestore. Every time I attempt to delete a user from my Firestore database, I receive an error stating that ._co.deleteConsulta is not a function, even though it was properly declared inside my detailpage.ts file with no errors showing up. I even tried running 'ionic serve --prod' to check for any missed errors, but found none.

In addition, whenever I click the delete button, nothing happens and no errors are displayed.

Here's my detail.ts:


import { AlertController } from '@ionic/angular';
import { FirestoreService } from './../../services/data/firestore.service';
import { Consulta } from './../../model/consulta.interface';
import { Component, OnInit } from '@angular/core';
import { Observable } from 'rxjs';
import { ActivatedRoute, Router } from '@angular/router';

@Component({
  selector: 'app-detail',
  templateUrl: './detail.page.html',
  styleUrls: ['./detail.page.scss'],
})
export class DetailPage implements OnInit {
  public consulta: Observable<Consulta>;
  public consultaId;
  constructor(private firestoreService: FirestoreService,
    private route: ActivatedRoute, private alertController: AlertController, private router: Router) { }

  ngOnInit() {
    const consultaId: string = this.route.snapshot.paramMap.get('id');
    this.consulta = this.firestoreService.getConsultaDetail(consultaId).valueChanges();
  }
  async deletarConsulta() {
    const alert = await this.alertController.create({
      message: 'Tem certeza que gostaria de desmarcar sua consulta?',
      buttons: [
        {
          text: 'Cancel',
          role: 'cancel',
          handler: blah => {
            console.log('Confirm desmarcação: blah');
          },
        },
        {
          text: 'Okay',
          handler: () => {
            this.firestoreService.deleteConsulta(this.consultaId).then(() => {
              this.router.navigateByUrl('');
            });
          },
        },
      ],
    });

    await alert.present();
  }

}

Here's my detail.html:

<ion-header>
    <ion-toolbar>
      <ion-buttons slot="start">
        <ion-back-button></ion-back-button>
      </ion-buttons>
      <ion-title>{{ (consulta | async)?.unidade }}</ion-title>
    </ion-toolbar>
  </ion-header>

  <ion-content padding>
      <h3> Unidade </h3>
      <p>
        Médico{{ (consulta | async)?.medNome }}
      </p>
      <p> Especialidade{{ (consulta | async)?.especialidade }}</p>
      <p> Endereço{{ (consulta | async)?.endereco }}</p>
      <p> Data da Consulta {{ (consulta | async)?.data }}</p>
      <p> Hora da Consulta {{ (consulta | async)?.hora }}</p>
      <ion-button expand="block" (click)="deletarConsulta()">
          Desmarcar Consulta
        </ion-button>
    </ion-content>

Answer №1

The issue here is that the deleteConsulta() function appears to be missing from your code, specifically in the firestoreService file. Additionally, consider modifying the access level from 'private' to 'public' in the Constructor declarations for potential resolution.

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

How can we manually initiate a state change from the server side to the client view in Angular Universal?

We are currently working on an Angular Universal application built with angular/cli version 1.4.3 and node version 6.9.5. Our issue lies in the transition between server-side view and client view. The switch occurs before we have obtained all the necessar ...

Using Angular: How to access a component variable within a CSS file

I'm having issues with my css file and attempting to achieve the following: .login-wrapper { background-image: url({{imagePath}}); } Below is my component code: export class LoginComponent implements OnInit { imagePath: any = 'assets/discord ...

Tips for optimizing vendor.js and main.js files in Angular 15 using NX workspace

Looking to enhance the performance of my login page and overall application by reducing the size of vendro.js and main.js files. Tried setting optimization : true in project.json for my NX workspace project, but it didn't work as expected. Currently ...

Typescript does not produce unused members

Having an issue with the JS code that TypeScript compiler is generating. Here's an example class: // Class export class UserDTO { Id: number; FirstName: string; LastName: string; DateOfBirth: Date; getFullName(): string { ...

The missing async pipe has caused an error in Spartacus when attempting to lazily load CMS components

Having trouble implementing Lazy Loading of CMS Components, I encountered the following error: ERROR Error: The pipe 'async' could not be found! It works perfectly with CSR, but SSR is giving issues. Using Spartacus 3.2.2 and Angular 10.2.3 in ...

Transition your Sequelize migrations to TypeORM

I'm currently in the process of transitioning a Node.js application from vanilla JS to Nest.js. In our previous setup, we used Sequelize as our ORM, but now we've decided to switch to TypeORM for its improved type safety. While exploring the Type ...

Ensuring Consistency of Values Between Child and Parent Components

Is there a way to ensure that the value of submitted in the child component always matches the value of submitted in the parent component? Appreciate any help! @Component({ selector: 'child-cmp', template: ` child:{{submitted}} ...

Displaying errors from an API using Angular Material mat-error

I am currently working on a form that includes an email field. Upon saving the form, the onRegisterFormSubmit function is called. Within this function, I handle errors returned by the API - specifically setting errors in the email form control and retrie ...

Dynamic Setting of Content-Type Header (Multipart/Data) Through Http Interceptor

I have been trying to upload a CSV file using an HttpInterceptor as a middleware. Everything works fine for normal requests, but I need to modify the request header to 'multipart/data' specifically for CSV uploads. Below is the code snippet: ex ...

Angular 2 Quickstart encountered a 404 error when trying to retrieve the /app/main.js

I'm attempting to follow the Angular 2 quickstart guide, but I'm having trouble getting it to work. I've searched for similar questions but haven't found a solution yet. Can anyone assist me with this? Here is my code: app.component.t ...

"Exploring the relationship between Vue checkbox components: parent and

Currently, I am working on a checkbox group where the behavior is such that if the parent checkbox is checked, all the child checkboxes will also be checked. Similarly, if a child checkbox is checked, the parent checkbox should also get checked, and so on. ...

The module 'pouchdb' appears to be missing, functioning correctly on Mac but encountering issues on Windows

I have taken over a project built with Ionic that was originally developed on a Mac by my colleague. I am now trying to run the project on my clean Windows 10 PC with Ionic, Cordova, and Python installed. However, I am encountering an error that my colleag ...

Performing unit tests in Angular 2 by utilizing a host component

Currently, I am diving into the world of unit testing in Angular2 v2.0.0. To kickstart my journey, I decided to utilize angular-cli to scaffold a project and execute unit tests using 'ng test'. The CLI gracefully generates a sample component alon ...

Mastering the latest NavigationStart feature in @angular-router version 3.0.0-alpha.*

I've noticed some interesting new events within the updated Angular 2 Router. There's NavigationStart, NavigationEnd, and NavigationFailed (or something similar). Is there anyone who has successfully implemented these events? I've tried a ...

Is there a way to inform TypeScript that the process is defined rather than undefined?

When I execute the code line below: internalWhiteList = process.env.INTERNAL_IP_WHITELIST.split( ',' ) An error pops up indicating, Object is possibly undefined. The env variables are injected into process.env through the utilization of the mod ...

Whenever I try to update my list of products, I encounter an error message stating that the property 'title' cannot be read because it is null

I am encountering an issue with editing data stored in the database. When attempting to edit the data, it is not displaying correctly and I am receiving a "cannot read property" error. HTML admin-products.component.html <p> <a routerLink="/ad ...

Having difficulty testing an Angular/NGXS action that triggers after an unsuccessful API request

Struggling with writing tests for an NGXS action that calls an http request? Want to add tests for both successful and failed requests? Here is the code for my Action: @Action(SearchChuckNorrisJokes) searchChuckNorrisJokes({ getState, setState }: StateCo ...

Learn the process of setting up a connection between Express JS and the NotionAPI using both POST and

As someone who is new to backend development, I am currently working on integrating a simple Notion form into a Typescript website. To guide me through the process, I found a helpful tutorial at . The tutorial demonstrates how to send data from localhost:3 ...

What is the best way to implement pipes and incorporate reusable action buttons in a Mat-table component for maximum reusability?

I am seeking assistance in creating a reusable component for the Angular Material Mat-table. I have made progress on loading data from the parent component to the child component, as can be seen in StackBlitz, but I now want to apply pipes to the data bef ...

Leveraging Angular's catchError method to handle errors and return

One of my challenges involves a model class that represents the server response: class ServerResponse { code: number; response: string; } Whenever I make api calls, I want the response to always be of type Observable<ServerResponse>, even in ...