【发布时间】:2019-08-09 21:52:31
【问题描述】:
我正在尝试在我的 Angular7 应用程序中使用新推出的 Firestore 模拟器。
根据this documentation,我在127.0.0.1:8080 上运行开发服务器:
firebase serve --only firestore
那么,在ng serve之后,如何让我的AngularFire模块使用数据库模拟器?
我在environment.ts 中尝试了以下操作:
export const environment = {
production: false,
name: 'local',
firebase: {
databaseURL: "http://127.0.0.1:8080"
}
};
但它不起作用,因为它需要一个“projectId”。我尝试将其设置为我的预生产 Firestore 数据库,但未使用开发服务器。
有没有想过?
这是我的app.module.ts:
import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { AppRoutingModule } from '@app/app-routing.module';
import { AppComponent } from '@app/app.component';
import { AngularFireModule } from '@angular/fire';
import { AngularFirestoreModule } from '@angular/fire/firestore';
import { AngularFireStorageModule } from '@angular/fire/storage';
import { AngularFireAuthModule } from '@angular/fire/auth';
import { environment } from '@env/environment';
@NgModule({
declarations: [
AppComponent
],
imports: [
BrowserModule,
AppRoutingModule,
AngularFireModule.initializeApp(environment.firebase, 'my-super-cool-app'),
AngularFirestoreModule,
AngularFireAuthModule,
AngularFireStorageModule
],
providers: [],
bootstrap: [AppComponent]
})
export class AppModule { }
【问题讨论】:
-
最新的firebase工具没有选项
--only firestore。唯一有效的目标是hosting和functions。就我现在而言,您只能为functions和hostinglocally 提供服务,而不是firestore。您必须使用在线firestore。 -
@fitzmode 它有,该选项处于测试阶段,请参阅firebase.google.com/docs/firestore/security/test-rules-emulator
标签: javascript angular firebase google-cloud-firestore angularfire2