我正在使用简单的值来提取一些数据,并在页脚中显示并获取此信息。
src / app / layout / customer / customerform / customerform.component.ts(25,7)中的错误:错误TS2322:类型“页脚”不能指定为“页脚[]”类型。 “页脚”类型中缺少属性“长度”。
Component.ts
footers: Footer[];
ngOnInit() {
this.getFooter();
console.log(this.footers);
}
getFooter() {
this.bone.getFooter().subscribe( actions => {
this.footers = actions.payload.data() as Footer;
});
}
model.ts
export interface Footer {
id?: string;
color?: string;
bg?: string;
text?: string;
}
service.ts
getFooter() {
return this.footerCollection.doc("style").snapshotChanges();
}
你需要改变从Footer
到Footer[]
的施法:
this.footers = actions.payload.data() as Footer[];
您需要初始化footers
以不获取undefined
错误:
footers: Footer[] = [];