There is no valid injection token found for the parameter 'functions' in the class 'TodosComponent'

While working in my code, I decided to use 'firebase' instead of '@angular/fire'. However, I encountered an issue that displayed the following error message:

No suitable injection token for parameter 'functions' of class 'TodosComponent'
.

The problematic section lies within todos.component.ts

import { Component, OnDestroy, OnInit } from '@angular/core';
import { TodosService } from '../todos.service';
import { Todo } from './Todo';
import * as functions from 'firebase/functions';

declare var StripeCheckout: StripeCheckoutStatic;

@Component({
  selector: 'app-todos',
  templateUrl: './todos.component.html',
  styleUrls: ['./todos.component.scss']
})
export class TodosComponent implements OnInit, OnDestroy {

  todos!: Todo[];
  localItem: string | null;
  completedTodos: number = 0;
  date: string = new Date().toUTCString();

  constructor(private functions: functions.Functions) {
      ..........
  }

  ......

}

I am struggling with the line of code

private functions: functions.Functions
.

Answer №1

Since you have imported directly from 'firebase/functions', there is no need to inject it in the constructor.

You can simply use the functions directly.

You should remove

private functions: functions.Functions
from the constructor.

Just use the functions directly without using this.functions.

For instance,

functions.firestore.document('/messages/{documentId}')

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

Creating a currency input field in HTML using a pattern textbox

In a project using HTML, Angular 2, and Typescript, I am working with a textbox. How can I ensure that it only accepts numbers along with either one dot or one comma? The input should allow for an infinite number of digits followed by a dot or a comma and ...

The Ionic 5 app features a white iframe that functions perfectly on the web platform

Whenever I run my web application's function, the iframe is displayed. However, on Android, all I see is a white screen. Can anyone assist with resolving this issue? HMTL html <ion-content> <ion-button expand="full" color="warning" (clic ...

The console.log() displays the dictionary correctly, but trying to access it with a key results in it being undefined

I'm currently facing an issue with accessing the dictionary stored in the "workload" field of a document in Firestore. Here is the snippet of code I am struggling with: async addTask() { const projectDoc = await getDoc(doc(db, "projects", "Testing ...

Learn the method for triggering events with a strongly-typed payload in Vue 3 Composition API and TypeScript

I'm currently exploring Vue 3 Composition API along with TypeScript, particularly focusing on emitting events with a strictly typed payload. There's an example provided below, but I'm unsure if it's the most effective way to achieve t ...

How to automatically scroll to the most recently added element in an *ngFor loop using Angular 2

In my web page, I have a dynamic list rendered using an ngFor loop. Users can add or remove elements from this list by clicking on a button. What I want to achieve is to automatically scroll the browser view to the latest element added when a user clicks o ...

Error: Unable to access _rawValidators property of null object

I'm currently facing an issue with formgroup and formcontrol in Angular. When I run ng serve, it's showing an error in the console. Does anyone have a solution for this? TypeError: Cannot read properties of null (reading '_rawValidators&a ...

Updating validators on Angular reactive form controls as they change

I am working with a reactive form where I need to dynamically adjust the validators for the "password" and "confirm password" fields based on user input. I have set up a subscription to listen for changes in the password field's value, updating the va ...

The Angular 13 interceptor is not capturing a 403 error as expected

When it comes to running a .NET 6 API, the Angular 13 application is encountering an issue with intercepting a 403 error. Strangely enough, the 401 error is being handled properly. The problem lies in the fact that the 403 error does not trigger the (err: ...

Having trouble generating a basic TypeScript definition file

I'm having trouble creating a definition file for vue-moment. While it compiles perfectly in IntelliJ, I encounter an issue with vue-cli build: This dependency was not found: * vue-moment in ./src/main.ts In my package.json, I added: "types": "typ ...

Contrast the different characteristics of string dynamic arrays in Angular 6

I am working with two arrays of strings. One array is a dynamic list of checkboxes and the other is the source to check if the item exists in the first array. I need to implement this dynamically using Angular 6, can you help me with this? Currently, the ...

How can a div be displayed next to another div when it is clicked using angular2?

Is there a way to have another page show up after clicking on a div, like shown in the image below? Before Click: After Click: ...

Automatically select the unique item from the list with Angular Material AutoComplete

Our list of document numbers is completely unique, with no duplicates included. I am attempting to implement a feature in Angular Material that automatically selects the unique entry when it is copied and pasted. https://i.stack.imgur.com/70thi.png Curr ...

Sharing data between two components in an Angular2-Meteor application

I am currently working with angular2-meteor. When attempting to transfer a value between two components (updating the value in the first component triggers an event in the second component where the new value is used), I have two methods available: The ...

Encountering unusual results while utilizing interfaces with overloaded arguments

I came across a situation where TypeScript allows calling a method with the wrong type of argument. Why doesn't the TypeScript compiler flag this as an issue? interface IValue { add(value: IValue): IValue; } class NumberValue implements IValue { ...

Encountering issues while attempting to run an npm install command on the package.json file

Having trouble running npm install to set up my Angular project on a Mac. It seems like the issues are due to working with an older project. npm ERR! code ERESOLVE npm ERR! ERESOLVE could not resolve npm ERR! npm ERR! While resolving: @angular-devkit/< ...

Can I format fixed text alongside a label in an angular material form to match the styling of an input, ensuring they have consistent typography?

I am currently creating a form using Angular material. I want to add static text and a styled label that mimics a form input without interactivity or underlining. By using a custom class, I managed to achieve this effect: <mat-form-field floatLa ...

Obtaining data from a BehaviorSubject for numerous dynamically generated components

As I work on developing a dynamic preview feature, I'm experimenting with drag-and-drop functionality to generate components in a canvas. These components can be duplicated within the same canvas, and upon dropping them, settings like styling are appl ...

Issue with mediaRecorder.ondataavailable in Angular 4 - need a solution

Currently, I am attempting to transmit real-time streaming data from an Angular 4 application to a NodeJS server. To achieve this, I have implemented the usage of socket.io and webRtc for streaming. constructor(private _chatService: ChatService) {} ngOnI ...

unable to utilize a tip with d3 version 5 in a TypeScript environment?

i'm facing an issue with the following code snippet: var tip = d3.tip() .attr('class', 'd3-tip') .attr('id', 'tooltip') .html(function(d) { return d; }) .direction('n ...

Having trouble dynamically rendering a Component using Object.entries

Looking to streamline my code, I am trying to iterate over a series of MUI rows using a loop and Object.entries. However, when attempting to extract the value of each separate Object, I encounter the following error: TS7053: Element implicitly has an &ap ...