sa_
sa_

Reputation: 2994

Angular 4 Supplied parameters do not match any signature of call target

I'm getting following error when I run my app with ng serve. But I can see the parameters, number of parameters are correct.

src/app/Services/customer.service.ts (27,20): Supplied parameters do not match any signature of call target.

service:

  //With Observable
  getCustomers(): Observable<Customer[]> {
    console.log('getCountries Service call starting...');
    let apiURL = `${this.apiRoot}Customers/`;
    return this.http.get(apiURL)
      .map(res => 
      {
        console.log('getCountries result: ' + res.text());
        return res.json().results.map(item => 
          {
            return new Customer(
              item.CustomerID,
              item.Username,
              item.Password,
              item.Email,
              item.Firstname,
              item.Lastname,
              item.Address,
              item.PostCode,
              item.City,
              item.OrderStatus,
              item.FK_CountryID,
              item.Country1,
              item.Picture,
              item.CreateDate
            );
          }
        )
      })
      .catch(error => {
        console.log(error);
        return Observable.throw(error.json());
      });
  } 

Model:

export class Customer {
    CustomerID:number
    Username:string
    Password:string
    Email:string
    Firstname:string
    Lastname:string
    Address:string
    PostCode:string
    City:string
    OrderStatus:string  
    FK_CountryID:number
    Country1:string
    Picture:string
    CreateDate:string
    constructor(CustomerID:number,Username:string,Password:string,Email:string,Firstname:string,
    Lastname:string, Address:string, PostCode:string, City:string, OrderStatus:string,FK_CountryID:number,
    Country1:string, Picture:string, CreateDate:string){
        this.CustomerID = CustomerID
        this.Username = Username
        this.Password = Password
        this.Email = Email
        this.Firstname = Firstname
        this.Lastname = Lastname
        this.Address = Address
        this.PostCode = PostCode
        this.City = City
        this.FK_CountryID = FK_CountryID
        this.Country1 = Country1
        this.Picture = Picture
        this.CreateDate = CreateDate
    }
}

Upvotes: 0

Views: 5019

Answers (2)

Faz Ahmad
Faz Ahmad

Reputation: 57

Seems its transpile issue, just stopped the app and run again with ng serve command. it worked for me

Upvotes: 0

sa_
sa_

Reputation: 2994

This is weird, I have only made a simple change and it worked, I think Cli couldn't build correctly so making a change in the model class made CLI build again(I guess).

So I changed this:

Country1:string, Picture:string, CreateDate:string){
        this.CustomerID = CustomerID

as following(I only press enter after {):

Country1:string, Picture:string, CreateDate:string)
{
    this.CustomerID = CustomerID

So literally I didn't make any change but force CLI to transpile again I think.

I also rollbacked this change and it worked fine again. !?!

Upvotes: 4

Related Questions