繁体   English   中英

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

[英]Type 'AngularFireObject<{}>' is not assignable to type 'ObservableInput<{}>'

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

    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;
}

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM