从Angular Web应用程序读取Firebase配置的步骤如下:
export const environment = {
production: false,
firebase: {
apiKey: 'YOUR_API_KEY',
authDomain: 'YOUR_AUTH_DOMAIN',
databaseURL: 'YOUR_DATABASE_URL',
projectId: 'YOUR_PROJECT_ID',
storageBucket: 'YOUR_STORAGE_BUCKET',
messagingSenderId: 'YOUR_MESSAGING_SENDER_ID'
}
};
export const environment = {
production: true,
firebase: {
apiKey: 'YOUR_API_KEY',
authDomain: 'YOUR_AUTH_DOMAIN',
databaseURL: 'YOUR_DATABASE_URL',
projectId: 'YOUR_PROJECT_ID',
storageBucket: 'YOUR_STORAGE_BUCKET',
messagingSenderId: 'YOUR_MESSAGING_SENDER_ID'
}
};
import { AngularFireModule } from '@angular/fire';
import { AngularFireAuthModule } from '@angular/fire/auth';
import { environment } from '../environments/environment';
@NgModule({
imports: [
AngularFireModule.initializeApp(environment.firebase),
AngularFireAuthModule
],
...
})
export class AppModule { }
这样,你就可以从Angular Web应用程序中成功读取Firebase配置了。请注意,上述步骤假设你已经安装了Firebase和AngularFire相关的依赖包,并且已经在Angular项目中正确配置了这些依赖项。
领取专属 10元无门槛券
手把手带您无忧上云