在angular2中如何将id值赋值给url
In angular2 How to assign id value to url
这里我把angular2 url部分写成
onselect(StateId: Country) {
var GetstateValue = this.http.post("http://localhost:34339/Home/GetStateById/",+StateId)
GetstateValue.subscribe(res => this.Success)
但它没有绑定 StateId 值(这里的 id 值即将到来)
Angular 获取和 POST
获取方法:
onselect(StateId: Country) {
var GetstateValue = this.http.get("http://localhost:34339/Home/GetStateById/"+StateId)
GetstateValue.subscribe(res =>{ this.Success=res; console.log(res);)
post方法
onselect(StateId: Country) {
const header = new Headers();
header.append('Content-Type', 'application/x-www-form-urlencoded');
let data = StateId;
var GetstateValue = this.http.post("http://localhost:34339/Home/GetStateById/", data, {headers: header}).map(res=>res.json());
GetstateValue.subscribe(res => this.Success);
这里我把angular2 url部分写成
onselect(StateId: Country) {
var GetstateValue = this.http.post("http://localhost:34339/Home/GetStateById/",+StateId)
GetstateValue.subscribe(res => this.Success)
但它没有绑定 StateId 值(这里的 id 值即将到来)
Angular 获取和 POST
获取方法:
onselect(StateId: Country) {
var GetstateValue = this.http.get("http://localhost:34339/Home/GetStateById/"+StateId)
GetstateValue.subscribe(res =>{ this.Success=res; console.log(res);)
post方法
onselect(StateId: Country) {
const header = new Headers();
header.append('Content-Type', 'application/x-www-form-urlencoded');
let data = StateId;
var GetstateValue = this.http.post("http://localhost:34339/Home/GetStateById/", data, {headers: header}).map(res=>res.json());
GetstateValue.subscribe(res => this.Success);