【发布时间】:2020-08-18 22:37:52
【问题描述】:
我为每位讲师收集了一组文档,并且我希望为每个文档收集另一个 cmets。我找不到阅读该子集的方法。这是结构:
我从这里的服务中获取特定的 ID:
getInstructor(iid: string) {
this.instructorDoc = this.afs.doc<Instructors>(`instructors/${iid}`);
return this.instructorDoc.valueChanges();
}
我在导师页面调用函数:
getInstructor(): void {
const iid = this.route.snapshot.paramMap.get('iid');
this.instructorsService.getInstructor(iid).subscribe(instructor => this.instructor = instructor);
}
我还有一个教师界面:
export interface Instructors {
iid: string;
first_name: string;
last_name: string;
category: string;
location: string;
description: string;
photoURL: string;
}
最后我得到了这样的讲师组件的 html:
<div *ngIf="instructor" class="card" style="width: 18rem;">
<img [src]="instructor.photoURL || '//:0'" alt="" class="card-img-top">
<div class="card-body">
<h5 class="card-title">{{ instructor.iid }} {{ instructor.first_name }} {{ instructor.last_name }}</h5>
<p class="card-text">Some quick example text to build on the card title and make up the bulk of the card's
content.</p>
</div>
</div>
所有代码都有效。我只是被卡住了,不知道如何从这里走。我应该在讲师界面中以某种方式声明 cmets 吗?还应该以某种方式获取评论的 id(可能在评论文档中添加 cid 字段)。以及我将如何在 html 中显示评论内容。我是 JavaScript/TypeScript/Angular 的新手,也许这些事情很简单,但我无法在 google 上找到有关特定情况的有用信息。
【问题讨论】:
标签: javascript angular typescript firebase google-cloud-firestore