Http 请求数据
import {
Http }
from
'@angular/http';
import
'rxjs/add/operator/map'
constructor(
public
http:
Http) {}
// get方式
this
.
http
.
get
(
url
)
.
map(
res
=>
res.
json())
.
subscribe(
res
=>{
console.
log(
res);
},
error
=> {
console.
log(
error);
});
// post方式
this
.
http
.
post
(
url
,
''
)
.
map(
res
=>
res.
json())
.
subscribe(
res
=>{
console.
log(
res);
},
error
=> {
console.
log(
error);
});