2016-11-04 3 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 transpiler가 오류라고 생각합니다. 중포 기지에 대한 귀하의 typings.json 파일에 typings 항목을 추가

    시도 :

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

    후 콘솔 창을 열고 typings install를 입력합니다.

    관련 문제