I\'m learning Angular looking for help in fixing the error: I\'m following this link : https://github.com/angular/angularfire2/blob/master/docs/install-and-setup.md to creat
I had same issue and below is resolved.
Old Service Code:
@Injectable()
Updated working Service Code:
@Injectable({
providedIn: 'root'
})
Open: ./src/app/app.module.ts
And import Firebase Modules at the top:
import { environment } from '../environments/environment';
import { AngularFireModule } from 'angularfire2';
import { AngularFirestoreModule } from 'angularfire2/firestore';
And VERY IMPORTANT:
Remember to update 'imports' in NgModule:
@NgModule({
declarations: [
AppComponent,
OtherComponent // Add other components here
...
],
imports: [
BrowserModule,
AngularFireModule.initializeApp(environment.firebase, 'your-APP-name-here'),
AngularFirestoreModule
],
...
})
Give it a try, it shall now work.
For detailed information follow the angularfire2 documentation:
https://github.com/angular/angularfire2/blob/master/docs/install-and-setup.md
Good luck!
I solved this problem by just removing firestore from:
import { AngularFirestore } from '@angular/fire/firestore/firestore';
in my component.ts file. as use only:
import { AngularFirestore } from '@angular/fire/firestore';
this can be also your problem.
I take that to my app.module. After the imports it should be works
providers: [
{ provide: LocationStrategy, useClass: HashLocationStrategy },
{ provide: FirestoreSettingsToken, useValue: {} }
],
My Version:
Angular CLI: 7.2.4
Node: 10.15.0
Angular: 7.2.5
... common, compiler, compiler-cli, core, forms
... language-service, platform-browser, platform-browser-dynamic
... router
Package Version
-----------------------------------------------------------
@angular-devkit/architect 0.12.4
@angular-devkit/build-angular 0.12.4
@angular-devkit/build-optimizer 0.12.4
@angular-devkit/build-webpack 0.12.4
@angular-devkit/core 7.2.4
@angular-devkit/schematics 7.2.4
@angular/animations 8.0.0-beta.4+7.sha-3c7ce82
@angular/cdk 7.3.2-3ae6eb2
@angular/cli 7.2.4
@angular/fire 5.1.1
@angular/flex-layout 7.0.0-beta.23
@angular/material 7.3.2-3ae6eb2
@ngtools/webpack 7.2.4
@schematics/angular 7.2.4
@schematics/update 0.12.4
rxjs 6.3.3
typescript 3.2.4
webpack 4.28.4
import angularFirebaseStore
in app.module.ts
and set it as a provider like service
For AngularFire2 Latest version
Install AngularFire2
$ npm install --save firebase @angular/fire
Then update app.module.ts file
import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { AppComponent } from './app.component';
import { FormsModule } from '@angular/forms';
import { AngularFireModule } from '@angular/fire';
import { AngularFireDatabaseModule } from '@angular/fire/database';
import { environment } from '../environments/environment';
import { AngularFirestoreModule } from '@angular/fire/firestore';
@NgModule({
declarations: [
AppComponent
],
imports: [
BrowserModule,
FormsModule,
AngularFireModule.initializeApp(environment.firebase),
AngularFirestoreModule,
AngularFireDatabaseModule
],
providers: [],
bootstrap: [AppComponent]
})
export class AppModule { }
Check FireStore CRUD operation tutorial here