我使用了Angular和.net core 2 API。我在Angular中构建了一个反应式表单,并尝试将其发布到API端,但问题是如果我将静态值传递给服务器然后它需要正确,但是当我尝试将表单值传递给API时它会变为空。 我不明白是什么问题。
这是我的组件代码:
private executeClientCreation(clientFormValue) {
let client1 = {
"FirstName": "abc",
"LastName": "xyz",
"BusinessName": "ABC & Co.",
"ClientType": "Company",
"DateOfBirth": "1995-09-16",
"Status": "Active",
"CreatedDate": "2018-06-04",
"Createdby": 1
};
let client2: Client = clientFormValue;
console.log("client1", client1);
console.log("client2", client2);
let apiUrl = 'client';
this.repository.create(apiUrl, client1)
.subscribe(res => {
( < any > $('#successModal')).modal();
},
(error => {
this.errorHandler.handleError(error);
this.errorMessage = this.errorHandler.errorMessage;
})
)
}
typescript接口:
export interface Client {
ClientID: number;
FirstName: string;
MiddleName: string;
LastName: string;
DateOfBirth: Date;
Gender: string;
BusinessName: string;
ClientType: string;
PANNumber: string;
AadharNumber: number;
NameAsPerAadhar: string;
}
c#class:
[Table("clientmaster")]
public class Client : BaseClass, IEntity
{
public int Id { get; set; }
public string FirstName { get; set; }
public string MiddleName { get; set; }
public string LastName { get; set; }
public string BusinessName { get; set; }
public string ClientType { get; set; }
public string Gender { get; set; }
public DateTime DateOfBirth { get; set; }
public string PANNumber { get; set; }
public long AadharNumber { get; set; }
public string NameAsPerAadhar { get; set; }
}