2017-05-11 45 views
0

這裏使用angular2在服務器端,當我嘗試插入從客戶端到服務器的值的數據IM是不是在服務器端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

結合試試這個:

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

      } 
相關問題