【发布时间】:2016-10-28 05:13:36
【问题描述】:
我尝试了一个连接到 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) 在评估 (http://localhost:4200/vendor/angularfire2/providers/firebase_sdk_auth_backend.js:108:4) 在评估 (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” 未定义的(…)
有什么想法吗?
【问题讨论】:
-
你的
AppComponent是什么样的? -
Main.ts文件很好,如果你有FacebookAuthProvider组件和服务,请给我们代码。 -
@Michael 我编辑了帖子。
-
@JS_astronauts:代码在这里:github.com/angular/angularfire2,它在图书馆中
-
这些安装正确吗? “angularfire2”:“^2.0.0-beta.2”,“firebase”:“^3.0.5”
标签: angular firebase angularfire firebase-authentication