Angular 数据没有显示。Ng反射Ng表示关闭:空?
嗨,我正在尝试从firebase绑定数据。我没有发现错误,但数据没有显示。在我得到的元素中Angular 数据没有显示。Ng反射Ng表示关闭:空?,angular,angularfire,angularfire2,Angular,Angularfire,Angularfire2,嗨,我正在尝试从firebase绑定数据。我没有发现错误,但数据没有显示。在我得到的元素中 <!--bindings={ "ng-reflect-ng-for-of": null }--> 如果需要app.module.ts,我可以添加它。所以问题是如何摆脱ng反射并显示我的数据。谢谢的ng-for-of评论是对Angular的绑定信息。即使在生产中,这些评论仍然会存在,尽管它们可能是空的 您是否从您的帖子中的app.component.ts中排除了代码 您的问题可能是由于组件
<!--bindings={
"ng-reflect-ng-for-of": null
}-->
如果需要app.module.ts,我可以添加它。所以问题是如何摆脱ng反射并显示我的数据。谢谢的
ng-for-of
评论是对Angular的绑定信息。即使在生产中,这些评论仍然会存在,尽管它们可能是空的
您是否从您的帖子中的app.component.ts
中排除了代码
您的问题可能是由于组件中未设置项
属性引起的。由于您使用的是async
管道,这意味着您希望项
是可观察的。请尝试按如下方式设置项目
属性:
@Component({
selector: "app-root",
templateUrl: "./app.component.html",
styleUrls: ["./app.component.css"]
})
export class AppComponent {
title = "app";
items: Observable<{title: string}>;
constructor(db: AngularFirestore) {
this.items = db.collection<{title: string}>('items').valueChanges();
}
}
@组件({
选择器:“应用程序根”,
templateUrl:“./app.component.html”,
样式URL:[“/app.component.css”]
})
导出类AppComponent{
title=“应用程序”;
项目:可观察;
建造商(db:AngularFirestore){
this.items=db.collection('items').valueChanges();
}
}
有关更多信息,请参阅
import { Component } from "@angular/core";
import { AngularFirestore } from "angularfire2/firestore";
import { Observable } from "rxjs/Observable";
import { AngularFire, FirebaseListObservable } from "angularfire2";
@Component({
selector: "app-root",
templateUrl: "./app.component.html",
styleUrls: ["./app.component.css"]
})
export class AppComponent {
title = "app";
constructor(db: AngularFirestore) {}
}
@Component({
selector: "app-root",
templateUrl: "./app.component.html",
styleUrls: ["./app.component.css"]
})
export class AppComponent {
title = "app";
items: Observable<{title: string}>;
constructor(db: AngularFirestore) {
this.items = db.collection<{title: string}>('items').valueChanges();
}
}