0
当我使用ng serve运行我的应用程序时,出现以下错误。 但我可以看到参数,参数个数是正确的。Angular 4提供的参数与呼叫目标的任何签名不匹配
src/app/Services/customer.service.ts(27,20):提供的参数不匹配调用目标的任何签名。
服务:
//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());
});
}
型号:
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
}
}
'.MAP(响应=> response.json()}'将工作你为什么这样?因为 –
Aravind
Customer类属性在服务器端不同,所以我需要一个与设置正确的属性上一个映射有角度的一面。 –