本文整理汇总了TypeScript中@angular/http.Jsonp类的典型用法代码示例。如果您正苦于以下问题:TypeScript Jsonp类的具体用法?TypeScript Jsonp怎么用?TypeScript Jsonp使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Jsonp类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。
示例1: getSearchResult
getSearchResult(tagName: string):Observable<Post[]> {
let searchUrl = `https://api.instagram.com/v1/tags/${tagName}/media/recent?access_token=${localStorage.getItem('ducky_access_token')}`;
var url = searchUrl + '&callback=JSONP_CALLBACK';
return this.jsonp.get(url)
.map(this.extractData)
.catch(this.handleError);
}
开发者ID:millionbots,项目名称:angularattack2016-rubber-ducks,代码行数:7,代码来源:SearchService.ts
示例2: getGeoDataForPostalCode
getGeoDataForPostalCode(postalCode, callback) {
var search = new URLSearchParams();
search.set('output', 'json');
search.set('q', this.pad(postalCode, 6));
search.set('client', '');
search.set('sensor', 'false');
// get address information from gothere.sg
this.jsonp.get(
'http://gothere.sg/maps/geo?callback=JSONP_CALLBACK', { search }
).map((response) => response.json()).subscribe(data => {
if (data.Status.code === 200) {
callback({
code: 200,
address: data.Placemark[0].AddressDetails.Country.Thoroughfare
.ThoroughfareName,
addressLine: data.Placemark[0].AddressDetails.Country.AddressLine, // (not all have) building, etc...
geolocation: {
lat: data.Placemark[0].Point.coordinates[1],
lng: data.Placemark[0].Point.coordinates[0]
}
})
} else {
callback({ code: 400 });
}
});
}
开发者ID:WeLoSG,项目名称:Frontend-Control-Center,代码行数:27,代码来源:map.service.ts
示例3: getOutboundBus
public getOutboundBus(route: string): any {
let baseUrl = 'http://realtime.mbta.com/developer/api/v2/schedulebyroutes';
let params = new URLSearchParams();
params.set('api_key', 'wX9NwuHnZU2ToO7GmGR9uw');
params.set('format', 'jsonp');
params.set('jsonpcallback', 'JSONP_CALLBACK');
params.set('routes', route);
params.set('max_trips', '5');
params.set('max_time', '1440');
return this.jsonp.get(baseUrl, {search: params}).map((req) => {
let routes = req.json().mode[0].route;
let data = [];
for (let myRoute of routes) {
for (let trip of myRoute.direction[0].trip){
data.push({
'route': myRoute.route_id,
'startTime': trip.stop[0].sch_dep_dt,
'startLocation': trip.stop[0].stop_name.replace(/ - Orange Line/g, '')
});
}
}
return data.sort((a, b) => a.startTime - b.startTime);
});
}
开发者ID:kdimatteo,项目名称:highlander,代码行数:27,代码来源:trains.service.ts
示例4: getHotMovie
getHotMovie(): Observable<any> {
return this.jsonp
.get(`https://api.douban.com/v2/book/1220562?format=json&callback=JSONP_CALLBACK`)
.map((response: Response) => {
return response.json();
});
}
开发者ID:qwb0920,项目名称:LlgApp,代码行数:7,代码来源:test.service.ts
示例5: searchWiki
// TODO: this would go in a service
private searchWiki(term: string): Observable<string[]> {
var params = new URLSearchParams();
params.set('action', 'opensearch');
params.set('search', term);
params.set('format', 'json');
return this._jsonp.get('http://en.wikipedia.org/w/api.php?callback=JSONP_CALLBACK', { search: params })
.map((res) => res.json()[1]);
}
开发者ID:ryanlangton,项目名称:angular2-rxjs,代码行数:9,代码来源:wikipedia-search-start.component.ts
示例6: getWords
getWords (limit: string): Promise<any>{
let apiUrl = 'https://wordsquiz.herokuapp.com/select';
let params = new URLSearchParams();
params.set('limit', limit);
params.set('callback', 'JSONP_CALLBACK');
return this.jsonp.request(apiUrl, {search: params}).toPromise();
}
开发者ID:ingpdw,项目名称:spellingQuiz,代码行数:8,代码来源:words.service.ts
示例7: rawsearch
rawsearch(term: string){
var search = new URLSearchParams();
search.set('action', 'opensearch');
search.set('search', term);
search.set('format', 'json');
return this.jsonp
.get('http://en.wikipedia.org/w/api.php?callback=JSONP_CALLBACK', { search })
.map(response => response.json()[1]);
}
开发者ID:AlmeroSteyn,项目名称:a11y-cli,代码行数:9,代码来源:wiki-service.service.ts
示例8: search
search (term: string) {
var search = new URLSearchParams()
search.set('action', 'opensearch');
search.set('search', term);
search.set('format', 'json');
return this.jsonp
.get('http://en.wikipedia.org/w/api.php?callback=JSONP_CALLBACK', { search })
.toPromise() // optional to convert Observable to Promise
.then((request) => request.json()[1]);
}
开发者ID:DavyDuDu,项目名称:ng2Boilerplate,代码行数:10,代码来源:WikiService.ts
示例9: search
search(term:string) {
let search = new URLSearchParams();
search.set('action', 'opensearch');
search.set('search', term);
search.set('format', 'json');
return this.jsonp
.get(`http://en.wikipedia.org/w/api.php?callback=JSONP_CALLBACK`, {search})
.map((res:Response) => res.json()[1])
.catch((err:any) => Observable.throw(err));
}
开发者ID:hoangpq,项目名称:es-ng2,代码行数:10,代码来源:wiki.service.ts
示例10: getInfo
/**
* getInfo from ip-api.com jsonp, ip optional
*/
getInfo(ip?: string){
let urlService = 'http://ip-api.com/json/';
let url;
ip ? url = `${urlService}${ip}` : url = urlService;
let params = new URLSearchParams();
params.set('callback', 'JSONP_CALLBACK');
return this.jsonp
.get(url, {search: params})
.map(this.extractData);
}
开发者ID:HenryGBC,项目名称:myIpInfo,代码行数:13,代码来源:ipinfo.service.ts
注:本文中的@angular/http.Jsonp类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论