Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angular/32.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
environment.ts或模块内部的Angularfire2 firebase配置?_Angular_Firebase_Angularfire2_Google Cloud Firestore - Fatal编程技术网

environment.ts或模块内部的Angularfire2 firebase配置?

environment.ts或模块内部的Angularfire2 firebase配置?,angular,firebase,angularfire2,google-cloud-firestore,Angular,Firebase,Angularfire2,Google Cloud Firestore,根据AngularFire2的官方文档,他们将初始配置放在environment.ts中,但我在其他任何地方都看到它放在app.component.module.ts文件(或他们正在使用的任何模块)中 哪个是正确的?如果两者都正确,哪一个是首选 谢谢两者都可以,但建议使用environment.ts,因为您可以有多个环境,例如一个用于开发,一个用于生产 如您所见,environment.ts在app.module.ts中导入和配置,默认行为为production:false 现在,您可以创建另一

根据AngularFire2的官方文档,他们将初始配置放在environment.ts中,但我在其他任何地方都看到它放在app.component.module.ts文件(或他们正在使用的任何模块)中

哪个是正确的?如果两者都正确,哪一个是首选


谢谢

两者都可以,但建议使用
environment.ts
,因为您可以有多个环境,例如一个用于开发,一个用于生产

如您所见,
environment.ts
app.module.ts
中导入和配置,默认行为为
production:false

现在,您可以创建另一个环境
environment.prod.ts
,并使用另一个firebase配置将其设置更改为
production:true

然后,当您说
ngbuild
时,将加载默认环境,并使用
ngbuild--prod
加载生产环境

环境命令在下的
angular cli.json
中配置

"environments": {
    "source": "environments/environment.ts",
    "dev": "environments/environment.ts",
    "prod": "environments/environment.prod.ts"
  }