angular / angularfire

Angular + Firebase = ❤️
https://firebaseopensource.com/projects/angular/angularfire2
MIT License
7.69k stars 2.19k forks source link

Connecting to two Firebase Apps #846

Closed danielfliegauf closed 7 years ago

danielfliegauf commented 7 years ago

The Firebase Docs describe quite nicely how to connect to two different apps.

// Initialize the default app firebase.initializeApp(defaultAppConfig);

// Initialize another app with a different config var otherApp = firebase.initializeApp(otherAppConfig, "other");

console.log(firebase.app().name); // "[DEFAULT]" console.log(otherApp.name); // "other"

// Use the shorthand notation to retrieve the default app's services var defaultStorage = firebase.storage(); var defaultDatabase = firebase.database();

// Use the otherApp variable to retrieve the other app's services var otherStorage = otherApp.storage(); var otherDatabase = otherApp.database();

I found on your GithubPages the following: https://github.com/angular/angularfire2/blob/master/docs/1-install-and-setup.md#custom-firebaseapp-names

But how do i get a reference within ng2 to this two firebase-apps? Could you maybe update your documentation?

Thank you a lot and 👍 for all this awesome work!! Daniel

mukesh51 commented 7 years ago

@danielfliegauf Not sure if I got your question, but are you asking how to connect to firebase from your angular2 App. Also, you're not following the issue template.

danielfliegauf commented 7 years ago

Hi Mukesh, thanks for the quick reply. I am using angularFire2 version beta0.7.

My Question is: "How can I connect in an Angualar2 app to two different Firebase Apps/RealTimeDatabases using angularFire2?"

¯_(ツ)_/¯---------------------------------------------------------

This is probably not right, is it?

@NgModule({ imports: [ BrowserModule, AngularFireModule.initializeApp(firebaseConfig, authConfig, 'my-app-name'), AngularFireModule.initializeApp(firebaseConfig2, authConfig2, 'my-app-name2') ], declarations: [ AppComponent ], bootstrap: [ AppComponent ] }) export class AppModule {}

¯_(ツ)_/¯----------------------------------------------------------

It would be great if you could update your docs and show how to do it the right way. Thank you! :)

ghost commented 7 years ago

up, plase help us

jaimealsilva commented 7 years ago

Checkout https://github.com/angular/angularfire2/issues/761

Toxicable commented 7 years ago

appears to be a duplicate of #761

can be closed

biowheel commented 7 years ago

@danielfliegauf . How did you solve the issue? While there have been many answers given, somehow I am not getting it. I was also wondering if we have to add the initialize method twice. How did you go about solving the issue? Thanks.