angularfire 2:错误“未处理的承诺拒绝:类型错误:无法读取属性"; [英] angularfire 2: Error "Unhandled Promise rejection: TypeError: Cannot read property"

查看:38
本文介绍了angularfire 2:错误“未处理的承诺拒绝:类型错误:无法读取属性";的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试了一个示例应用来连接到 Firebase

I tried an example app to connect to Firebase

在我的 Main.ts 中我写了这个:

In my Main.ts I wrote this:

import { bootstrap } from '@angular/platform-browser-dynamic';
import { enableProdMode } from '@angular/core';
import { AppComponent, environment } from './app/';
import { FIREBASE_PROVIDERS, defaultFirebase, firebaseAuthConfig, AuthProviders, AuthMethods } from 'angularfire2';

if (environment.production) {
  enableProdMode();
}

bootstrap(AppComponent,[
  FIREBASE_PROVIDERS,
  defaultFirebase({
    apiKey: "MYKEY",
    authDomain: "MYDOMAIN.firebaseapp.com",
    databaseURL: "https://MYDOMAN.firebaseio.com",
    storageBucket: "MYDOMAIN.appspot.com",
  }),
  firebaseAuthConfig({
    provider: AuthProviders.Password,
    method: AuthMethods.Popup
  })
]);

这是 component.ts

here is the component.ts

import { Component } from '@angular/core';
import { LoginComponent } from './login/'

@Component({
  moduleId: module.id,
  selector: 'app-root',
  templateUrl: 'app.component.html',
  styleUrls: ['app.component.css'],
  directives: [ LoginComponent ]
})
export class AppComponent {
  title = 'Please Login to the App';
}

但是当使用ng serve"启动我的应用程序并调用 URL 时,我收到一个错误消息:

But when is start my App with "ng serve" and call the URL , I get an error called:

zone.js:461 未处理的承诺拒绝:类型错误:无法读取未定义的属性FacebookAuthProvider"在 Object.eval (http://localhost:4200/vendor/angularfire2/提供者/firebase_sdk_auth_backend.js:24:43)在 eval (http://localhost:4200/vendor/angularfire2/providers/firebase_sdk_auth_backend.js:108:4)在 eval (http://localhost:4200/vendor/angularfire2/providers/firebase_sdk_auth_backend.js:109:3)在 Object.eval (http://localhost:4200/vendor/angularfire2/angularfire2.js:33:35)评估http://localhost:4200/vendor/angularfire2/providers/firebase_sdk_auth_backend.js评估 http://localhost:4200/vendor/angularfire2/angularfire2.js评估 http://localhost:4200/app/login/login.component.js评估 http://localhost:4200/app/login/index.js 评估http://localhost:4200/app/app.component.js 评估http://localhost:4200/app/index.js 评估http://localhost:4200/main.js 加载错误http://localhost:4200/main.js ;区域: ;任务:Promise.then;值:错误:类型错误:无法读取属性FacebookAuthProvider"未定义的(…)

zone.js:461 Unhandled Promise rejection: TypeError: Cannot read property 'FacebookAuthProvider' of undefined at Object.eval (http://localhost:4200/vendor/angularfire2/providers/firebase_sdk_auth_backend.js:24:43) at eval (http://localhost:4200/vendor/angularfire2/providers/firebase_sdk_auth_backend.js:108:4) at eval (http://localhost:4200/vendor/angularfire2/providers/firebase_sdk_auth_backend.js:109:3) at Object.eval (http://localhost:4200/vendor/angularfire2/angularfire2.js:33:35) Evaluating http://localhost:4200/vendor/angularfire2/providers/firebase_sdk_auth_backend.js Evaluating http://localhost:4200/vendor/angularfire2/angularfire2.js Evaluating http://localhost:4200/app/login/login.component.js Evaluating http://localhost:4200/app/login/index.js Evaluating http://localhost:4200/app/app.component.js Evaluating http://localhost:4200/app/index.js Evaluating http://localhost:4200/main.js Error loading http://localhost:4200/main.js ; Zone: ; Task: Promise.then ; Value: Error: TypeError: Cannot read property 'FacebookAuthProvider' of undefined(…)

有什么想法吗?

推荐答案

根据评论,似乎在使用 Firebase 2.x SDK 而不是 AngularFire2 所需的 Firebase 3.x SDK 时会发生此错误.

Based on the comments, it appears that this error occurs when using the Firebase 2.x SDK instead of the Firebase 3.x SDK which is required by AngularFire2.

这篇关于angularfire 2:错误“未处理的承诺拒绝:类型错误:无法读取属性";的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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