1 | initial version |
To add Firebase to an Ionic Angular 7 application, follow these steps:
npm install firebase @angular/fire --save
import { AngularFireModule } from '@angular/fire';
import { AngularFireAuthModule } from '@angular/fire/auth';
@NgModule({
imports: [
AngularFireModule.initializeApp(environment.firebase),
AngularFireAuthModule
]
})
export class AppModule { }
import { AngularFireAuth } from '@angular/fire/auth';
export class MyComponent {
constructor(private afAuth: AngularFireAuth) {}
}
You can now use the Firebase services in your application. For example, to authenticate a user with email and password, you can use the following code:
this.afAuth.auth.signInWithEmailAndPassword(email, password)
.then(userCredential => {
// The user is signed in.
})
.catch(error => {
// Handle errors here.
});