当我使用ng服务运行我的应用时,我收到了以下错误。 但我可以看到参数,参数数量是否正确。
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
}
}
答案 0 :(得分:4)
这很奇怪,我只做了一个简单的更改并且它有效,我认为Cli无法正确构建,因此在模型类中进行更改使CLI再次构建(我猜)。
所以我改变了这个:
CreatureBehavior
如下(我只在{)之后按Enter键:
def select_user_role (user)
@user = user
collection_select(:user, :role, User.roles.to_a, :first, :first, {}, {
data: {user_id: @user.id},
onChange: ""
})
end
所以从字面上看,我没有做任何改动,但强迫CLI再次反复思考。
我也回滚了这个变化,它又恢复了正常。 !?!
答案 1 :(得分:0)
似乎出现了可移植问题,只是停止了该应用程序,然后使用ng serve命令再次运行。它对我有用