Calvin Ferrando
Calvin Ferrando

Reputation: 4082

AngularFire 2 - FirebaseApp vs FirebaseRef

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

Answers (1)

Frank van Puffelen
Frank van Puffelen

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

Related Questions