0

I am working on angular2seedadvanced with Firebase. While using Firebase service inside my component its not working. How can I use service inside the component in angular2seedadvanced. I am following

Here I attach my code files.

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

public 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();
}
}

getting an error

this.databaseService.authenticate is not a function.

What should I do? How can I solve this issue. Thanks in advance.

adjuremods
  • 2,938
  • 2
  • 12
  • 17
Khushi
  • 1,759
  • 6
  • 26
  • 45

1 Answers1

0

If you don't have the typings installed then the TypeScript transpiler will think it's an error.

Try adding a typings entry in your typings.json file for firebase:

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

then open a console window and type typings install.

For reference: https://github.com/ChuckkNorris/SkillPath/blob/master/typings.json

Levi Fuller
  • 13,631
  • 4
  • 38
  • 44