Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/string/5.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
Angular 具有id值的父键的角度4_Angular_Typescript_Ngfor - Fatal编程技术网

Angular 具有id值的父键的角度4

Angular 具有id值的父键的角度4,angular,typescript,ngfor,Angular,Typescript,Ngfor,我想从UserHardware接收所有带有所有父键的值 随机生成的键中的子节点具有以下结构:name:Test,desc:Test 构造函数(组件)中的我的代码 在(模板)中 它可以工作,我可以通过使用 {{item.name}}` {{item.key}}` {{item.desc}}` 当我没有指定UID时,如何使其工作?我怀疑您想这样做 this.userHardwareList = db.list('UserHardware/'); this.items = this.userHa

我想从UserHardware接收所有带有所有父键的值 随机生成的键中的子节点具有以下结构:
name:Test,desc:Test

构造函数(组件)中的我的代码

在(模板)中

它可以工作,我可以通过使用

{{item.name}}` {{item.key}}` {{item.desc}}`

当我没有指定UID时,如何使其工作?

我怀疑您想这样做

 this.userHardwareList = db.list('UserHardware/');
this.items = this.userHardwareList.snapshotChanges().map(changes => {
  return changes.map(c => ({ key: c.payload.key, data:c.payload.val() }));
});
然后


{{item.key}

{{data.name}{{data.desc}}


this.userHardwareList = db.list('UserHardware/udwcGxqx50ZtoF8EABoFh8GVet2');
{{item.name}}` {{item.key}}` {{item.desc}}`
 this.userHardwareList = db.list('UserHardware/');
this.items = this.userHardwareList.snapshotChanges().map(changes => {
  return changes.map(c => ({ key: c.payload.key, data:c.payload.val() }));
});
<li *ngFor="let item of items | async">
 {{item.key}}
  <ol>
    <li *ngFor="let data of items">
      {{data.name}}{{data.desc}}
    </li>
  <ol>
</li>