当我尝试将数据从客户端插入到服务器时,我在服务器端使用 angular2 值在服务器端没有绑定
状态.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);
}
试试这个:
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);
}
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句