angularfire
angularfire copied to clipboard
NullInjectorError: No provider for InjectionToken angularfire2.app.options!
Hello,
I have the same issue but it is not in the test file. It is in my dev environment and below is the code of the x.component.ts file.
import { Component, OnInit } from '@angular/core';
import { GroupService } from '../shared/group.service';
import { NgForm } from '@angular/forms';
// import { NullTemplateVisitor } from '@angular/compiler';
import { AngularFirestore } from '@angular/fire/firestore';
// import { AngularFireModule } from 'angularfire2';
// import { AngularFirestoreModule } from 'angularfire2/firestore';
@Component({
selector: 'app-group',
templateUrl: './group.component.html',
styleUrls: ['./group.component.css']
})
export class GroupComponent implements OnInit {
constructor(private groupService: GroupService, private firestore: AngularFirestore) { }
ngOnInit() {
this.resetForm();
}
resetForm(form ?: NgForm){
if(form!= null)
form.resetForm();
this.groupService.formData = {
$key : null,
firstname: '',
lastname: '',
age: null
}
}
onSubmit(form : NgForm){
let data = form.value;
// this.firestore.collection('groups').add(data);
this.resetForm(form);
}
}
The error I get is as below.
ERROR Error: StaticInjectorError(AppModule)[AngularFirestore -> InjectionToken angularfire2.app.options]:
StaticInjectorError(Platform: core)[AngularFirestore -> InjectionToken angularfire2.app.options]:
NullInjectorError: No provider for InjectionToken angularfire2.app.options!
at NullInjector.push../node_modules/@angular/core/fesm5/core.js.NullInjector.get (core.js:8895)
at resolveToken (core.js:9140)
at tryResolveToken (core.js:9084)
at StaticInjector.push../node_modules/@angular/core/fesm5/core.js.StaticInjector.get (core.js:8981)
at resolveToken (core.js:9140)
at tryResolveToken (core.js:9084)
at StaticInjector.push../node_modules/@angular/core/fesm5/core.js.StaticInjector.get (core.js:8981)
at resolveNgModuleDep (core.js:21217)
at _createClass (core.js:21270)
at _createProviderInstance (core.js:21234)
Are you initializing the AngularFireModule as outlined in the docs? https://github.com/angular/angularfire2/blob/master/docs/install-and-setup.md#5-setup-ngmodule-for-the-angularfiremodule