Angular + Firebase-无法获取html

问题描述

我想基于数据库中对象的键导航到URL,但是当我访问p。$ key值时始终未定义。

服务:

 getAll(){
    return this.db.list('/products').valueChanges();
  }

组件:

 products$;

  constructor(private productService: ProductService) { 

    this.products$ = this.productService.getAll();
    
  }

html:

<table class="table">
    <thead>
        <tr>
            <th>Title</th>
            <th>Price</th>
            <th></th>
        </tr>
    </thead>
    <tbody>
        <tr *ngFor="let p of products$ | async">
            <td>{{p.title}}</td>
            <td>{{p.price}}</td>
            <td>
                <a [routerLink]="['/admin/products/',p.$key]" >Edit</a>
            </td>
        </tr>
    </tbody>
</table>

enter image description here

我为p.title和p.price获得了正确的值,但是p。$ key始终未定义。我也尝试过p.key,同样的事情。

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)