我正在将数据插入Firebase db中,一旦我提交了成功插入的表单数据,但是在TypeScript文件中遇到了错误,有什么能告诉我我在做什么错吗?在代码中。
这是我的registerpage.ts代码
regPhotographer = {} as RegPhotographer;
regPhotographerRef$: AngularFireList<RegPhotographer[]>;
constructor( private db: AngularFireDatabase, public router: Router ) {
this.regPhotographerRef$ = this.db.list('register');
}
addPhotographer(regPhotographer: RegPhotographer): void{
this.regPhotographerRef$.push({
fname: this.regPhotographer.fname,<!--The Error Line-->
lname: this.regPhotographer.lname,
location: this.regPhotographer.location,
area: this.regPhotographer.area,
amount: this.regPhotographer.amount,
pin: this.regPhotographer.pin
});
这是我的registeruser.ts页面代码。
export interface RegPhotographer {
fname: string;
lname: string;
location: string;
area: string;
amount: string;
pin: string;
}
答案 0 :(得分:0)
您的AngularFireList
的类型为RegPhotographer
,而不是RegPhotographer[]
。它已经是列表,而不是数组列表。
regPhotographerRef$: AngularFireList<RegPhotographer>;