我试图创建一个简单的表单来将数据推送到Firebase服务器。使用当前代码,可以将数据添加到服务器,但是当我想获取该数据并将其显示为li时,会给我错误“ HomeComponent.html:19错误错误:InvalidPipeArgument:'[object Object]'for管道“ AsyncPipe””。对于任何人来说,这可能都是一个简单的问题,但是对我来说,此时获取正确的代码很困难,所以谢谢您的时间,
Home.component.ts:
import { Component, OnDestroy } from '@angular/core';
import { AngularFireDatabase, AngularFireList } from 'angularfire2/database';
@Component({
selector: 'home',
templateUrl: './home.component.html',
styleUrls: ['./home.component.css']
})
export class HomeComponent{
backups$: AngularFireList<{}>;
constructor(db: AngularFireDatabase) {
this.backups$ = db.list('/backups');
}
add(backup: HTMLInputElement){
this.backups$.push({
naam: (backup.value),
url: "test.nl",
datum: "01-01-2019"
});
backup.value = '';
}
}
Home.component.html:
<h4>Backups</h4>
<input type="text" (keyup.enter)="add(backup)" #backup>
<ul>
<li *ngFor="let backup of backups$ | async">{{ backup.naam }} <span class="align-right-list">{{ backup.datum }}</span></li>
</ul>