Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Angular 7:TypeError: Class constructor Observable cannot be invoked without 'new'

this.db.object('/users/'+user.uid).update({
  name:user.displayName,email:user.email
  });
}

getting this error :

core.js:9110 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:20)
     at SafeSubscriber._next (app.component.ts:23)
     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)
 defaultErrorLogger @ core.js:9110
like image 857
Naidu Giridhar Avatar asked Dec 17 '22 16:12

Naidu Giridhar


2 Answers

Go to tsconfig.json,

Change the target from es2015 to es5.

This worked for me.

I think the compiler is still having issues when you use the AngularFire Database methods, I am not 100% sure of the cause, but changing the target solved the issue immediately and my user field was easily created in the DataBase

like image 55
Benneee_ Avatar answered Jan 06 '23 01:01

Benneee_


change TARGET in TSCONFIG.JSON from es2015 to es5 and then recompile with ng serve

like image 43
abhay pratap singh Avatar answered Jan 06 '23 02:01

abhay pratap singh