类型“ AngularFireObject <{}>”不可分配给类型“ ObservableInput <{}>”

时间:2019-02-07 10:16:34

标签: ionic3 angular5

我正面临这个问题,请问有人可以帮助我解决此错误吗 类型“ AngularFireObject <{}>”不能分配给类型“ ObservableInput <{}>”。类型'AngularFireObject <{}>'中缺少属性'length',但类型'ArrayLike <{}>'中必需 在data.service.ts

    import { Injectable } from '@angular/core';
    import { AngularFireDatabase, AngularFireObject, AngularFireList} 
          from 'angularfire2/database';
    import { User, database } from 'firebase/app';
    import { Profile } from '../../models/profile/profile.interface';
    import "rxjs/add/operator/take";
    import "rxjs/add/operator/map";
    import "rxjs/add/operator/mergeMap";
    import firebase from 'firebase';
    import { AuthService } from '../auth/auth.service';
    import { USER_LIST } from '../../mocks/profile/profile';

  constructor (private database: AngularFireDatabase) {
  }

  getAuthenticatedUserProfile() {
     return this.auth.getAuthenticatedUser()
     .map(user => user.uid)
     .mergeMap(authId => this.database.object(`profiles/${authId}`)) <--error
     .take(1);
   }
  `

在我的auth.service.ts中

constructor(private auth: AngularFireAuth) {
  console.log('Hello AuthProvider Provider');
}

getAuthenticatedUser () {
   return this.auth.authState;
}

0 个答案:

没有答案