错误TS2740:类型'DocumentChangeAction <{}> []'缺少类型的以下属性

时间:2019-03-09 21:50:28

标签: firebase google-cloud-firestore angular7

我在搜索栏中遇到问题。

我的问题是如何从firebase中获取数据并使其成角度地放在前端。

我尝试提供一种搜索名称的服务:

import { Injectable } from '@angular/core';
import { AngularFirestore } from '@angular/fire/firestore';


@Injectable({
  providedIn: 'root'
 })
export class FirebaseService {

 constructor(public db: AngularFirestore) {

 }
   searchUsers(searchValue){
    return this.db.collection('Mot',ref => ref.where('Kurde', '>=', 
   searchValue)
  .where('Kurde', '<=', searchValue + '\uf8ff'))
  .snapshotChanges()
  }
}

我的组件就是这样:

  import { Component, OnInit, NgZone } from '@angular/core';
import { FirebaseService } from '../../shared/services/firebase.service';
import { Observable } from 'rxjs';
import { AngularFirestore } from '@angular/fire/firestore';



export interface Mot {
  Kurde: string;
  Francais: string;
  Iran:string;
  Turquie:string;
  syrie:string;
  Pro:string;
  Iraq:string;
};

@Component({
  selector: 'app-recherche',
  templateUrl: './recherche.component.html',
  styleUrls: ['./recherche.component.css']
})
export class RechercheComponent implements OnInit {
 Motinfo: Mot = {
   Kurde: '',
   Francais: '',
   Iran:'',
   Turquie:'',
   syrie:'',
   Pro:'',
   Iraq:'',
 };
  constructor( public firebaseService: FirebaseService,
) {

}

  ngOnInit() {
  }
  rechercheKurde(kurde) {
    this.firebaseService.searchUsers(kurde)
    .subscribe(result => {
      this.Motinfo = result;
      console.log(result)
    })
}
}

所以它给了我一个错误:

  ../../components/recherche/recherche.component.ts(43,7)中的

错误:   错误TS2740:类型'DocumentChangeAction <{}> []'缺少   “ Mot”类型的以下属性:库尔德,法兰西,伊朗,Turquie,   还有3个。

我在firebase中的数据库如下:

enter image description here

0 个答案:

没有答案