Here im using angular2 at server side when i try to insert data from client to server values is not binding at server side
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);
}
Try this:
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);
}