【发布时间】:2018-12-27 12:41:29
【问题描述】:
我正在尝试将我的后端 api 与前端集成。我收到以下错误。 找不到名称“cus_id”。 找不到名称“用户名”。 找不到名称“全名”.etc
预计“位置和状态”所有其他属性名称都是错误的。Error
Customer.component.ts
constructor(private fb: FormBuilder, private cs: CustomerService, private ps: ProductService) {}
ngOnInit() {
this.createForm();
this.showSuccess = false;
this.getProductList();
}
createForm() {
this.customer_addForm = this.fb.group({
username: [''],
cus_id: [''],
email: [''],
fullname: [''],
customer_currency: [''],
mobile_primary: [''],
website: [''],
country: [''],
location: [''],
city: [''],
postal_code: [''],
status: [''],
productList: ['']
});
}
submitcustomeraddForm() {
this.showSuccess = false;
this.allProducts = _.uniq[this.allProducts];
this.cs.addCustomer(username,
cus_id, email,
fullname, customer_currency,
mobile_primary, website,
country, location,
city,
postal_code,
status,
productList);
}
Customer.service.ts
export class CustomerService {
uri = 'http://localhost:3000/customer';
constructor(private http: HttpClient) { }
addCustomer(username,
cus_id, email,
fullname, customer_currency,
mobile_primary, website,
country, location,
city,
postal_code,
status,
productList) {
const obj = {
username: username,
cus_id: cus_id,
email: email,
fullname: fullname,
customer_currency: customer_currency,
mobile_primary: mobile_primary,
website: website,
country: country,
location: location,
city: city,
postal_code: postal_code,
status: status,
productList: productList
};
return this.http.post(`${this.uri}/add`, obj).subscribe(res => console.log('done'));
}
我已经在网上搜索了解决方案,但我没有找到。我不知道为什么它显示未找到。
【问题讨论】:
标签: typescript angular6 angular2-services