0
votes

i got an error like this:

core.js:6014 ERROR TypeError: Class constructor Observable cannot be invoked without 'new'

at new FirebaseObjectObservable (firebase_object_observable.js:16)    
at FirebaseObjectFactory (firebase_object_factory.js:7)    
at AngularFireDatabase.push../node_modules/angularfire2/database/database.js.AngularFireDatabase.object (database.js:18)    
at UserService.save (user.service.ts:12)
at SafeSubscriber.next (app.component.ts:17)
at SafeSubscriber.__tryOrUnsub (Subscriber.js:185)    
at SafeSubscriber.next (Subscriber.js:124)
at Subscriber.next (Subscriber.js:72)
at Subscriber.next (Subscriber.js:49    
at Notification.observe (Notification.js:20)
import { Injectable } from '@angular/core';
import { AngularFireDatabase } from 'angularfire2/database';
import * as firebase from 'firebase';

@Injectable()
export class UserService {        
    constructor(private db: AngularFireDatabase) { }
    save(user: firebase.User){
        this.db.object('/users/' + user.uid).update({
            name:user.displayName,
            email:user.email
        });
    }
}
1
Did you initialize firebase in your app.module.ts via your config object? - Enes Yalçın
yes @EnesYalçın i did initialize it : AngularFireModule.initializeApp(environment.firebase) - Harshdeep Singh
changed "target": "es2015", in the tsconfig file to "es5" . It worked - Harshdeep Singh

1 Answers

1
votes

For all those who get stuck on this in future, try changing "target": "es2015", in the tsconfig file to "es5" . It worked for me.