本文整理汇总了TypeScript中@angular/common/http.HttpClient.jsonp方法的典型用法代码示例。如果您正苦于以下问题:TypeScript HttpClient.jsonp方法的具体用法?TypeScript HttpClient.jsonp怎么用?TypeScript HttpClient.jsonp使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类@angular/common/http.HttpClient
的用法示例。
在下文中一共展示了HttpClient.jsonp方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: getMetrics
// Gets requested metric data
getMetrics(metric?: String) : Observable <Metric[]>{
var metricsURL = 'http://service.iris.edu/mustang/metrics/1/query?output=jsonp&nodata=200';
if (metric)
metricsURL += metric;
return this.http.jsonp(metricsURL,"callback")
.pipe(
map(this.mapMetrics),
catchError((error: Error) => {
return observableThrowError(error);
})
);
}
示例2: search
search(query): Promise<SearchResult[]> {
const params = new HttpParams() //
.set('name', query) //
.set('minScore', '0.7') //
.set('itemsPerPage', '10') //
.set('outputSRS', '4326') //
.set('embed', '0') //
.set('outputStyle', 'detail') //
.set('outputFormat', 'jsonx') //
.set('callback', 'JSONP_CALLBACK') //
.toString();
return this.http.jsonp(
`https://apps.gov.bc.ca/pub/bcgnws/names/soundlike?${params}`,
'jsonp12345'
).toPromise().then(data => {
const matches: SearchResult[] = [];
const found = false;
const features = data['features'];
if (features) {
for (const feature of features) {
const props = feature.properties;
const name = props.name;
let label = name;
let featureType = props.featureType;
if (featureType) {
const parenStartIndex = featureType.indexOf('(');
const parenEndIndex = featureType.indexOf(')');
if (parenStartIndex !== -1 && parenEndIndex > parenStartIndex) {
featureType = featureType.substring(0, parenStartIndex) + featureType.substring(parenEndIndex + 1);
}
label += ' (' + featureType + ')';
}
label += ' ' + props.feature.relativeLocation;
matches.push(new SearchResult(
props['uri'],
label,
props['featurePoint']
));
}
}
return matches;
});
}
示例3:
jsonp<TResponseBody>(url: string, callbackParam: string): Observable<TResponseBody> {
return this.httpClient.jsonp<TResponseBody>(url, callbackParam);
}