當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript HttpClient.jsonp方法代碼示例

本文整理匯總了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);
       })
   );
 }
開發者ID:pnsn,項目名稱:mustangular,代碼行數:13,代碼來源:metrics.service.ts

示例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;
   });
 }
開發者ID:IanLaingBCGov,項目名稱:FWA_Visualization,代碼行數:43,代碼來源:geographic-name-search.component.ts

示例3:

 jsonp<TResponseBody>(url: string, callbackParam: string): Observable<TResponseBody> {
     return this.httpClient.jsonp<TResponseBody>(url, callbackParam);
 }
開發者ID:jbload,項目名稱:Muscularity,代碼行數:3,代碼來源:http-client-wrapper.service.ts


注:本文中的@angular/common/http.HttpClient.jsonp方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。