【问题标题】:filtring data from firebase to angular从firebase过滤数据到角度
【发布时间】:2021-03-25 13:49:39
【问题描述】:

--我的目标--

过滤我的数据并将其显示在表格上 --预期结果--

显示我过滤的数据

--我试过的--


 getData(){
    this.firebaseService.getUsers()
    .subscribe(result => {
      this.items = result;
      this.id_order_filltered_items = result;
      this.phone_filtered_items = result;
      this.heure_filtered_items = result;
      this.NOMchauffeu_filtered_items = result;

    })
  }
 ngOnInit() {
    this.getData();
    console.log('hey',this.searchValue)
  }
searchByName(){
  let value = this.searchValue.toLowerCase();
  this.firebaseService.searchUsers(value)
  .subscribe(result => {
    this.NOMchauffeu_filtered_items = result;
    this.items = this.combineLists(result, this.phone_filtered_items);
  })

---
my service

 searchUsersByAge(value){
    return this.db.collection('commandes',ref =>
    ref.orderBy('phone').startAt(value)).snapshotChanges();
   }

我真的很感激帮助 我是 Firebase 的新手

【问题讨论】:

    标签: angular firebase firebase-realtime-database google-cloud-firestore


    【解决方案1】:

    我不完全确定你在尝试什么,但你可以尝试这样的事情(还没有测试过)

    命令

    export interface commandes{
        items ?: any;
        id_order_filltered_items ?:any
        phone_filtered_items ?: any
        heure_filtered_items ?: any
        NOMchauffeu_filtered_items?:any
      }
    

    ..

    commandes: Commandes
    
     ngOnInit() {
        this.commandes = myService.searchUsersByAge(10).subscribe(x => {this.commandes = x; console.log('hey',this.commandes)} )
        
      }
    

    我的服务

     searchUsersByAge(value){
              return this.db.collection<commandes>('commandes', ref =>
                     ref.orderBy('phone').startAt(value)).snapshotChanges();)}
    

    【讨论】:

    • 对不起,我会在表格中显示数据后尝试解释一下我放置了一个搜索按钮,以便我可以过滤数据但我的过滤器不起作用我想创建一个过滤器功能所以当我输入我的搜索输入时,我可以过滤我的数据
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2022-01-03
    • 2022-11-27
    • 2019-03-24
    • 1970-01-01
    • 2016-06-29
    • 2020-10-10
    • 2019-04-10
    相关资源
    最近更新 更多