【发布时间】:2019-02-27 14:26:32
【问题描述】:
我正在尝试以角度访问 firestore 数据库中的数据。
这是我的组件:
import { Component, OnInit } from '@angular/core';
import { Observable } from 'rxjs';
import {AngularFirestore, AngularFirestoreCollection, AngularFirestoreDocument} from 'angularfire2/firestore';
interface Mission {
cliente: string;
luogo: string;
materiale: string;
nCassoni: number;
nota: string;
operatore: string;
}
@Component({
selector: 'app-check-mission',
templateUrl: './check-mission.component.html',
styleUrls: ['./check-mission.component.css']
})
export class CheckMissionComponent{
missionsCol: AngularFirestoreCollection<Mission>;
missions: any;
constructor(private db: AngularFirestore) {
}
ngOnInit(){
this.missionsCol = this.db.collection('mission');
this.missionsCol.valueChanges().subscribe((_missions: any) => {
this.missions = _missions;
console.log(this.missions);
}
}
这是我的 html:
<ul *ngFor="let mission of missions | async">
<li>
{{ mission.cliente }}
</li>
</ul>
在 Firestore 中,我在 mission 下有 6 个文档,实际上在 html 页面中我看到了六个点,但除了一切都是空白的!
我做错了什么?
更新
--我已经更新了代码,现在我可以在控制台中记录结果,但是我看不到 html 中的 deata。
控制台给了我这个错误nvalidPipeArgument: '[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]' for pipe 'AsyncPipe'
at invalidPipeArgumentError ..
【问题讨论】:
标签: json angular google-cloud-firestore