Angular2为什么数据在服务器端没有绑定

时间:2017-05-11 06:41:36

标签: angular2-services

这里我在服务器端使用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);

            }

1 个答案:

答案 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);

            }