服务档案:
import { Injectable } from '@angular/core';
import {AngularFireAuth} from 'angularfire2/auth';
import {Observable} from 'rxjs/Observable';
import * as firebase from 'firebase/app';
@Injectable()
export class AfService {
user: Observable<firebase.User>;
constructor(public afAuth : AngularFireAuth){
this.user=afAuth.authState;
}
loginWithGoogle(){
const provider= new firebase.auth.GoogleAuthProvider();
this.afAuth.auth.signInWithPopup(provider);
}
logout(){
this.afAuth.auth.signOut();
}
}
app.module:
import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import {AngularFireModule} from 'angularfire2';
import {AngularFireDatabaseModule,AngularFireDatabase} from 'angularfire2/database';
import {AppRoutingModule} from './app-routing-module';
import { AppComponent } from './app.component';
import {environment} from '../environments/environment';
import { PagesListComponent } from './pages-list/pages-list.component';
import { LoginPageComponent } from './login-page/login-page.component';
import {AfService} from './providers/af.service';
import {AngularFireAuthModule} from 'angularfire2/auth';
@NgModule({
declarations: [
AppComponent,
PagesListComponent,
LoginPageComponent,
],
imports: [
BrowserModule,
AngularFireModule.initializeApp(environment.firebase),
AngularFireDatabaseModule,
AppRoutingModule,
AngularFireAuthModule
],
providers: [AfService],
bootstrap: [AppComponent]
})
export class AppModule { }
编译时出错 -
*******命名空间'“/ Users / Triathlon / Desktop / cms / cms-app / node_modules / firebase / app / index”'没有导出的成员'User'。
属性'auth'在类型'typeof“/ Users / Triathlon / Desktop / cms / cms-app / node_modules / firebase / app / index”'上不存在。**