Angular2为什么数据在服务器端没有绑定(Angular2 why data is not binding at server side)
这里即时使用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); }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); }最满意答案
尝试这个:
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); }更多推荐
GetstateValue,new,State,服务器,电脑培训,计算机培训,IT培训"/> <meta name="d
发布评论