Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angular/31.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
带firebase的Angular 4材质自动完成_Angular_Firebase_Firebase Realtime Database_Angularfire - Fatal编程技术网

带firebase的Angular 4材质自动完成

带firebase的Angular 4材质自动完成,angular,firebase,firebase-realtime-database,angularfire,Angular,Firebase,Firebase Realtime Database,Angularfire,我无法输出和筛选firebase的$key对象。 加载时,出现以下错误: 错误:找不到类型为“object”的不同支持对象“[object]”。NgFor只支持绑定到数组之类的可重用文件 我的火力基地 "clients" : { "222" : { ... }, "1111" : { ... }, "42423424" : { ... }, "242342342" : { ... },

我无法输出和筛选firebase的$key对象。 加载时,出现以下错误: 错误:找不到类型为“object”的不同支持对象“[object]”。NgFor只支持绑定到数组之类的可重用文件

我的火力基地

"clients" : {
    "222" : {
      ...
    },
    "1111" : {
      ...
    },
    "42423424" : {
      ...
    },
    "242342342" : {
     ...
    },
    "453533535" : {
      ...
    },
    "822233311" : {
     ...
    },
    "89510135551" : {
     ...
    },
    "89510145553" : {
     ...
    }
  }
我的html

<md-input-container>
  <input mdInput placeholder="State" [mdAutocomplete]="auto" [formControl]="clientCtrl">
</md-input-container>
<md-autocomplete #auto="mdAutocomplete">
  <md-option *ngFor="let state of filteredClient | async" [value]="state.$key">
    {{ state.$key }}
  </md-option>
</md-autocomplete>

{{state.$key}}
还有我的ts文件

clientbase: FirebaseListObservable<any[]>;
clientCtrl: FormControl;
filteredClient: any;
 constructor(private af: AngularFire){
 this.clientbase = af.database.list('/clients/');

    this.clientCtrl = new FormControl();
     this.filteredClient = this.clientCtrl
                               .valueChanges
                               .startWith(null)
                               .map(name => this.filterClient(name));
}

  filterClient(val: string) {
    return val ? this.clientbase
       .map(list => list.filter(
       s =>  new RegExp(`^${val}`, 'gi')
       .test(s.$value)
    )) : this.clientbase;
  }
clientbase:FirebaseListObservable;
clientCtrl:FormControl;
过滤客户:任何;
建造师(私人af:AngularFire){
this.clientbase=af.database.list('/clients/');
this.clientCtrl=新表单控件();
this.filteredClient=this.clientCtrl
.价值变动
.startWith(空)
.map(name=>this.filterClient(name));
}
filterClient(val:string){
return val?this.clientbase
.map(list=>list.filter(
s=>newregexp(`^${val}`,'gi')
.测试(s.$值)
)):this.clientbase;
}

按如下方式更改代码:

clientbase:any[];
clientCtrl:FormControl;
过滤客户:任何;
建造师(私人af:AngularFire){
af.database.list(“/clients/”)
.subscribe(items=>{this.clientbase=items;});
this.clientCtrl=新表单控件();
this.filteredClient=this.clientCtrl
.价值变动
.startWith(空)
.map(name=>this.filterClient(name));
}
filterClient(val:string){
返回val&&this.clientbase?
这是我的客户群
.filter(s=>newregexp(`^${val}`,'gi').test(s.$value))
:this.clientbase;
}

这样对我很有效。

你找到解决办法了吗?