简体   繁体   English

类型的参数不能分配给类型的参数。对象文字只能指定已知的属性

[英]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[] . 看来您的AngularFireListAngularFireList类型, RegPhotographer不是RegPhotographer[]类型。 It is already a list not a list of arrays. 它已经是列表,而不是数组列表。

regPhotographerRef$: AngularFireList<RegPhotographer>;

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 对象文字只能指定已知属性 - Object Literal May Only Specify Known Properties 对象字面量只能指定已知的属性,并且类型“设置”中不存在“选择” - Object literal may only specify known properties, and 'select' does not exist in type 'Settings' 错误TS2322:对象文字可能仅指定已知属性,并且类型中不存在“标签” - error TS2322: Object literal may only specify known properties, and 'labels' does not exist in type Object 文字可能只指定已知属性,并且“设置”类型中不存在“按钮” - Object literal may only specify known properties, and 'buttons' does not exist in type 'Settings 对象文字只能指定已知的属性,并且&#39;ChatMessage []&#39;类型中不存在&#39;message&#39; - Object literal may only specify known properties and 'message' does not exist in type 'ChatMessage[]' 错误:对象字面量只能以角度指定已知属性 - error: Object literal may only specify known properties in angular Object 文字只能指定已知属性 Angular/TypeScript - Object literal may only specify known properties Angular/TypeScript 对象文字可能只指定已知属性错误 - Object literal may only specify known properties error Angular Object文字只能指定知道属性,而...在类型中不存在 - Angular Object literal may only specify know properties and … does not exist in type angular 4 typescript 验证错误对象文字可能只指定已知属性 - angular 4 typescript validation error Object literal may only specify known properties
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM