Reputation: 4082
I want to get the ref to enable me to use .update() method. I can exactly use FirebaseApp / FirebaseRef and do this:
private ref1: any;
private ref2: any;
constructor(@Inject(FirebaseApp) fbApp: any, @Inject(FirebaseRef): fbRef: any) {
this.ref1 = fbApp.database().ref();
this.ref2 = fbRef.database().ref(); // which work exactly as this.ref1
}
What is the difference between FirebaseApp and FirebaseRef? And which one is recommended to use? Thanks
Upvotes: 1
Views: 146
Reputation: 598728
Both give you a reference to the root of the database. Functionally they do exactly the same. But I find the first one much clearer, so would always use that - unless you're aiming to complicate code maintenance.
Upvotes: 2