使用Angular4和Angularfire2(v4)在Firebase中获取用户身份验证配置文件信息

时间:2017-05-07 20:26:31

标签: angular firebase angularfire2

看看这个solution(angular2),我一直在尝试使用相同的功能在angular4中工作并且做得很短。我得到的错误是:

“Auth”

类型中不存在“订阅”属性

以下是一些示例代码(不工作):

angularFire.ts(提供者):

import {Injectable} from "@angular/core";
import { Observable } from 'rxjs/Observable';
import { FirebaseObjectFactoryOpts } from "angularfire2/interfaces";
import { AngularFireDatabaseModule, AngularFireDatabase, FirebaseListObservable, FirebaseObjectObservable } from 'angularfire2/database';
import { AngularFireAuthModule, AngularFireAuth } from 'angularfire2/auth';
import * as firebase from 'firebase/app';

@Injectable()
export class AF {
  public messages: FirebaseListObservable<any>;
  public users: FirebaseListObservable<any>;
  public displayName: string;
  public email: string;
  public user: Observable<firebase.User>;

  constructor(private afAuth: AngularFireAuth, private db: AngularFireDatabase) {
    this.afAuth.auth.subscribe(
      (auth) => {
        if (auth != null) {
          this.user = db.list.object('users/' + auth.uid);
        }
      });
    this.messages = db.list('messages');
    this.users = db.list('users');
  } ... 
}

0 个答案:

没有答案