Firebase 返回“app/bad-app-name"在 angularfire2 中 [英] Firebase returns "app/bad-app-name" in angularfire2

查看:26
本文介绍了Firebase 返回“app/bad-app-name"在 angularfire2 中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的 Angular 应用中,Firebase 返回一个错误,将 bad-app-name 显示为代码.我在 angular 应用程序中使用 angularfire2.

In my Angular app Firebase returns an error which shows bad-app-name as code. i'm using angularfire2 in angular app.

我已经仔细检查了 Firebase 配置,没问题,那么如何解决这个错误.

I have double checked Firebase configuration, it is alright, so how to solve this error.

app.components.ts

import { Component, OnInit } from '@angular/core';
import { FormsModule, NgForm } from "@angular/forms";
import { AngularFireDatabase } from "angularfire2/database";
import { Router } from '@angular/router';

@Component({
  selector: 'app-root',
  templateUrl: './app.component.html',
  styleUrls: ['./app.component.css']
})
export class AppComponent{
  isLoggedIn: boolean = false;
  courses: any[];
  constructor(public db: AngularFireDatabase) {
    db.list('/Courses').valueChanges().subscribe(courses => {
      this.courses = courses;
      console.log(this.courses);
    });
  }

  login() {
    this.isLoggedIn = !this.isLoggedIn;
  }
  user:any;
  saveData(formData) {
    if (formData.valid) {
      console.log(formData.value);
    }
  }
}

app.module.ts

import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { FormsModule, ReactiveFormsModule } from "@angular/forms";
import { HttpModule } from "@angular/http";
import { AppRoutingModule } from './app-routing.module';

import { AngularFireModule } from "angularfire2";
import { AngularFireDatabaseModule } from "angularfire2/database";
import { AngularFireAuthModule } from "angularfire2/auth";

import { AppComponent } from './app.component';

export const firebaseConfig = {
  apiKey: "apikey",
  authDomain: "angular-f5fa9.firebaseapp.com",
  databaseURL: "https://angular-f5fa9.firebaseio.com",
  projectId: "angular-f5fa9",
  storageBucket: "angular-f5fa9.appspot.com",
  messagingSenderId: "592083773091"
};

@NgModule({
  declarations: [
    AppComponent
  ],
  imports: [
    BrowserModule,
    AppRoutingModule,
    AngularFireModule.initializeApp(firebaseConfig),
    AngularFireDatabaseModule,
    AngularFireAuthModule,
    FormsModule,
    ReactiveFormsModule,
    HttpModule
  ],
  providers: [],
  bootstrap: [AppComponent]
})
export class AppModule { }

控制台错误

FirebaseError {
code: "app/bad-app-name", 
message: "Firebase: Illegal App name: '[object Object] (app/bad-app-name).", 
name: "[object Object]", 
ngDebugContext: DebugContext_, 
ngErrorLogger: ƒ, …}

推荐答案

对我有用的解决方案:

npm uninstall --save firebase angularfire2

然后

npm install angularfire2 firebase --save

这篇关于Firebase 返回“app/bad-app-name"在 angularfire2 中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆