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


TypeScript http.Jsonp類代碼示例

本文整理匯總了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;未經允許,請勿轉載。