angularfire 2:错误"未处理的承诺拒绝:TypeError:无法读取属性"

时间:2016-06-25 20:41:11

标签: angular firebase angularfire firebase-authentication

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

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

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

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,我收到一个名为:

的错误
  

zone.js:461未处理的承诺拒绝:TypeError:无法读取   财产' FacebookAuthProvider'未定义的         在Object.eval(http://localhost:4200/vendor/angularfire2/providers/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;   值:错误:TypeError:无法读取属性' FacebookAuthProvider'   未定义的(...)

有什么想法吗?

1 个答案:

答案 0 :(得分:0)

根据评论,使用Firebase 2.x SDK而不是AngularFire2所需的Firebase 3.x SDK时,会出现此错误。