本文整理匯總了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);
}