我正在使用github中的angular2seed-advanced。
我需要将firebase与我的应用集成。为此我遵循这个documentation,遗憾的是我无法整合并遇到一些错误。
我在这里附上我的文件。
main.web.ts
import { enableProdMode } from '@angular/core';
import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
// platfrom module
import { WebModule } from './web.module';
import { Config, DatabaseService } from './app/frameworks/core/index';
import { FIREBASE } from './app/frameworks/demoapp/index';
Config.PLATFORM_TARGET = Config.PLATFORMS.WEB;
Config.DEBUG.LEVEL_4 = true;
// app
import { WindowService, ConsoleService } from './app/frameworks/core/index';
import { CoreModule } from './app/frameworks/core/core.module';
import { ANALYTICS_PROVIDERS } from './app/frameworks/analytics/index';
import { MultilingualService } from './app/frameworks/i18n/index';
import { AppConfig } from './app/frameworks/sample/services/app-config';
import { SampleModule } from './app/frameworks/sample/sample.module';
import { AppComponent } from './app/components/app.component';
MultilingualService.SUPPORTED_LANGUAGES = AppConfig.SUPPORTED_LANGUAGES;
declare var require: any
var firebase = require("firebase/app");
require("firebase/auth");
require("firebase/database");
if (String('<%= ENV %>') === 'prod' || String('<%= TARGET_DESKTOP_BUILD %>') === 'true') {
enableProdMode();
}
let BOOTSTRAP_PROVIDERS: any[] = [
DatabaseService,
provide(FIREBASE, { useValue: firebase })=======> Error cannot find module provide
];
platformBrowserDynamic().bootstrapModule(WebModule, BOOTSTRAP_PROVIDERS);
login.component.ts
import { BaseComponent } from '../../frameworks/core/index';
import { DatabaseService } from '../../frameworks/demoapp/services/database.service';
import { Component } from '@angular/core';
@Component({
selector: 'demo-login',
templateUrl: 'path',
styleUrls: ['path']
})
export class LoginComponent {
constructor(private databaseService: DatabaseService) {
}
login() {
this.databaseService.authenticate(); =====> Edited
}
}
database.service.ts
import { Injectable, Inject, NgZone } from '@angular/core';
import { FIREBASE } from '../../demoapp/index';
@Injectable()
export class DatabaseService {
private database: any;
private onSync: Function;
private userID: string;
constructor( @Inject(FIREBASE) firebase: any, private ngZone: NgZone)
{
console.log('Constructing DatabaseService');
// Initialize Firebase
var config = {
// your web config from Firebase console
};
firebase.initializeApp(config);
this.database = firebase.database();
}
public authenticate() {
======>Edited
};
}
在构造函数中提供数据库服务时,我无法加载我的应用程序并收到错误
&#34;没有Token firebase的提供者!&#34;
如何解决此问题。
答案 0 :(得分:0)
provide(FIREBASE, { useValue: firebase })=======> Error cannot find module provide
应该是
{ provide: FIREBASE, useValue: firebase }
很久以前,这种语法发生了变化。
答案 1 :(得分:-1)
如果您查看github.com/jlooper/PocketRave,您可以看到使用此种子的完整Firebase集成