标签:OLE amp rom port err console his color com
1、通过 Http
同步请求:
import {Http,Jsonp} from "@angular/http";
constructor(private http:Http,private jsonp:Jsonp) { }
this.http.get("http://www.phonegap100.com/appapi.php?a=getPortalList&catid=20&page=1").subscribe(
function(data){
console.log(data);
},function(err){
console.log(‘失败‘);
}
);
异步请求:
import {Http,Jsonp} from "@angular/http";
import {Observable} from "rxjs";
import "rxjs/Rx";
constructor(private http:Http,private jsonp:Jsonp) { }
this.http.get("http://www.phonegap100.com/appapi.php?a=getPortalList&catid=20&page=1").map(
res => res.json()).subscribe(
function(data){
console.log(data);
}
);
2、通过 Jsonp
同步请求:
import {Http,Jsonp} from "@angular/http";
constructor(private http:Http,private jsonp:Jsonp) { }
this.jsonp.get("http://www.phonegap100.com/appapi.php?a=getPortalList&catid=20&page=1&callback=JSONP_CALLBACK").subscribe(
function(data){
console.log(data);
},function(err){
console.log(‘失败‘);
}
);
异步请求:
import {Http,Jsonp} from "@angular/http";
import {Observable} from "rxjs";
import "rxjs/Rx";
constructor(private http:Http,private jsonp:Jsonp) { }
this.jsonp.get("http://www.phonegap100.com/appapi.php?a=getPortalList&catid=20&page=1&callback=JSONP_CALLBACK").map(
res => res.json()).subscribe(
function(data){
console.log(data);
}
);
3、RxJs
标签:OLE amp rom port err console his color com
原文地址:https://www.cnblogs.com/yuyedaocao/p/9326740.html