2017-05-11 32 views
0

在i值分配給URL作爲Angular2錯誤爲:GetStateById /%221%500 22(內部服務器錯誤)

onselect(id: number) { 
     let data = JSON.stringify(id) 
     let headers = new Headers({'Content-Type': 'application/x-www-form-urlencoded' }); 
     let options = new RequestOptions({ headers: headers }); 
     var GetstateValue = this.http.get("http://localhost:34339/Home/GetStateById" + '/' + data, options) 
     GetstateValue.subscribe((res => this.Success(res)), res => this.Error(res)); 
    } 

Throughing錯誤作爲內部服務器錯誤爲:34339 /主頁/ GetStateById /%221 %22當我點擊該URL它給我的http://localhost:34339/Home/GetStateById/"1"我怎樣才能從我的網址

回答

3

也許你可以使用背面取下「」蜱

var GetstateValue = this.http.get(`http://localhost:34339/Home/GetStateById/${id}`, options)

Template Strings

希望這會有幫助