Hello im trying to implement firestore into my web application, when i add the service to contructor the error:
NullInjectorError: No provider for TesteventService!
I'm using Angular 5, angularfire2/firestore and typescript 2.7.1
testevent.service.ts
import { Injectable } from '@angular/core'; import { AngularFirestore } from 'angularfire2/firestore' @Injectable() export class TesteventService { constructor(private afs: AngularFirestore) { } addEvent(eventData){ this.afs.collection('testevent').add(eventData).then(() => { console.log('Done'); }) } getEvent(){ return this.afs.collection('testevent', ref => ref.orderBy('id')).valueChanges() } }
component.ts
import { Component, OnInit } from '@angular/core'; import { TesteventService } from '../../providers/testevent.service'; import { AngularFirestore } from 'angularfire2/firestore'; export class CsvImportComponent implements OnInit { data_rows = [] constructor(private event: TesteventService){})
When I add events from TesteventSerivice i get the error, while nothing is run.
You need to add TesteventService under providers under imports in your app.module.ts
providers: [ TesteventService ]
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With