2016-11-04 5 views
0

私は、firebaseでangular2seedadvancedに取り組んでいます。私のコンポーネントの中でFirebaseサービスを使用している間は動作しません。 angular2seedvancedのコンポーネントの内部でサービスを使用するにはどうすればいいですか?私はangular2seedのサービスをどのように使用するのですか

  • https://github.com/jlooper/pocketrave
  • https://github.com/NathanWalker/angular-seed-advanced/wiki/How-to-integrate-Firebase-across-all-platforms-(web-nativescript-desktop)

      を次しています。

    ここで私のコードファイルを添付します。エラー

    this.databaseService.authenticateを取得

    login.component.ts

    import { Store } from '@ngrx/store'; 
    import { BaseComponent } from '../../frameworks/core/index'; 
    import { DatabaseService } from '../../frameworks/demoapp/services/database.service'; 
    import { Component } from '@angular/core'; 
    
    @Component({ 
    moduleId: module.id, 
    selector: 'demo-login', 
    providers: [DatabaseService], 
    templateUrl: './login.component.html', 
    styleUrls: ['./login.component.css'] 
    }) 
    export class LoginComponent { 
    
    constructor(private databaseService: DatabaseService) { 
    
    } 
    
    login() { 
    
    this.databaseService.authenticate(); 
    } 
    } 
    

    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 
        apiKey: "", 
        authDomain: "", 
        databaseURL: "", 
        storageBucket: "" 
    }; 
    firebase.initializeApp(config); 
    this.database = firebase.database(); 
    }; 
    
    public authenticate() { 
    
    }; 
    

    firebase.service.tsは関数ではありません。

    どうすればよいですか?どうすればこの問題を解決できますか?前もって感謝します。

  • 答えて

    0

    タイピングがインストールされていない場合、TypeScriptトランスペラレータはエラーだとみなします。 firebaseのためにあなたのtypings.jsonファイルにタイピングエントリを追加

    試してみてください。

    "firebase": "registry:dt/firebase#2.4.1+20160412125105",

    は、コンソールウィンドウを開き、typings installを入力します。

    参考: https://github.com/ChuckkNorris/SkillPath/blob/master/typings.json

    関連する問題