[英]Argument of type is not assignable to parameter of type .Object literal may only specify known properties
我将数据插入Firebase数据库中,一旦提交提交的表单数据成功但在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;
}
看来您的AngularFireList
是AngularFireList
类型, RegPhotographer
不是RegPhotographer[]
类型。 它已经是列表,而不是数组列表。
regPhotographerRef$: AngularFireList<RegPhotographer>;
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.