[英]Argument of type is not assignable to parameter of type .Object literal may only specify known properties
I am inserting the data in Firebase db, once I submit the form data inserted successfully but am getting the error in TypeScript file, can any tell me what I am doing wrong? 我将数据插入Firebase数据库中,一旦提交提交的表单数据成功但在TypeScript文件中却收到错误,可以告诉我我做错了什么吗? In the code. 在代码中。
Here is my code of registerpage.ts 这是我的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
});
Here is my registeruser.ts page code. 这是我的registeruser.ts页面代码。
export interface RegPhotographer {
fname: string;
lname: string;
location: string;
area: string;
amount: string;
pin: string;
}
It looks like your AngularFireList
is of type RegPhotographer
not RegPhotographer[]
. 看来您的AngularFireList
是AngularFireList
类型, RegPhotographer
不是RegPhotographer[]
类型。 It is already a list not a list of arrays. 它已经是列表,而不是数组列表。
regPhotographerRef$: AngularFireList<RegPhotographer>;
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.