这里我在服务器端使用angular2,当我尝试从客户端向服务器值插入数据时,在服务器端没有绑定
state.ts
export class State {
Sts_Id: number;
Sts_Name: string;
Cnt_Id: number;
}
StateObj: State = new State()
StateArray: Array<State> = new Array<State>();
SaveState(saveState: State) {
let headers = new Headers({ 'Content-Type': 'application/json; charset=utf-8'});
let options = new RequestOptions({ headers: headers});
var GetstateValue = this.http.post("http://localhost:34339/Home/StatePost" + '/' + saveState, options);
GetstateValue.subscribe((res => this.Success(res)), res => this.Error(res));
console.log(GetstateValue);
}
答案 0 :(得分:0)
试试这个:
export class State {
Sts_Id: number;
Sts_Name: string;
Cnt_Id: number;
}
StateObj: State = new State()
StateArray: Array<State> = new Array<State>();
SaveState(saveState: State) {
let headers = new Headers({ 'Content-Type': 'application/json; charset=utf-8'});
let options = new RequestOptions({ headers: headers});
var GetstateValue = this.http.post("http://localhost:34339/Home/StatePost",{saveState}, options);
GetstateValue.subscribe((res => this.Success(res)), res => this.Error(res));
console.log(GetstateValue);
}