It has been an awesome experience following the learning paths on the sitepoint premium, but I have been stuck for a long time as a have a bit of challenge with the "Building a Realtime Database With Firebase Course. Particular stuck at the creating the firebase config service. my firebase project does not print to the console, but instead i get an invalid object in the console.
My Core Module:
import { NgModule, ModuleWithProviders, Optional, SkipSelf } from '@angular/core';
// Services
import { FirebaseConfigService } from './service/firebase-config.service';
@NgModule({
imports: [ ],
declarations: [ ],
exports: [ ]
})
export class CoreModule {
constructor(@Optional() @SkipSelf() parentModule: CoreModule) {
if (parentModule) {
throw new Error("CoreModule exists already. Only import in the root/app module");
}
}
static forRoot(): ModuleWithProviders {
return {
ngModule: CoreModule,
providers: [FirebaseConfigService ]
};
}
}
my FirebaseconfigService:
import { Injectable } from '@angular/core';
import * as firebase from 'firebase';
import { FIREBASE_CONFIG } from '../constant/constants';
@Injectable()
export class FirebaseConfigService {
constructor() {
this.configureApp();
}
configureApp() {
const app = firebase.initializeApp(FIREBASE_CONFIG);
console.log(app); // TODO: REMOVE
}
}
Console response:
Invalid object localhost:3000:26:52
<anonymous>
http://localhost:3000/:26:52
ZoneDelegate.prototype.invoke
http://localhost:3000/node_modules/zone.js/dist/zone.js:232:17
Zone.prototype.run
http://localhost:3000/node_modules/zone.js/dist/zone.js:114:24
scheduleResolveOrReject/<