简体   繁体   中英

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? In the code.

Here is my code of 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.

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[] . It is already a list not a list of arrays.

regPhotographerRef$: AngularFireList<RegPhotographer>;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM