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


TypeScript http.Jsonp類代碼示例

本文整理匯總了TypeScript中angular2/http.Jsonp的典型用法代碼示例。如果您正苦於以下問題:TypeScript Jsonp類的具體用法?TypeScript Jsonp怎麽用?TypeScript Jsonp使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了Jsonp類的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: lookup

    lookup(symbol: string) {
        let url = `http://finance.yahoo.com/webservice/v1/symbols/${symbol}/quote?format=json&view=detail&callback=JSONP_CALLBACK`;
        // .catch(...)

        return this._jsonp.get(url)
            .map(r => +r.json().list.resources[0].resource.fields.price);
    }
開發者ID:ChrisFulstow,項目名稱:angularity,代碼行數:7,代碼來源:stock.service.ts

示例2: search

 search(keyword) {
   let params = new URLSearchParams('callback=JSONP_CALLBACK');
   params.set('term', keyword);
   return this.jsonp.request('https://itunes.apple.com/search', {
     search: params
   }).map(response => response.json().results);
 }
開發者ID:AllanSmithee83,項目名稱:as-ionic2-iTunesApp,代碼行數:7,代碼來源:itunes.ts

示例3: searchQuotes

  searchQuotes(query: string): Observable<QuoteSearch[]> {

    var search: URLSearchParams = new URLSearchParams();
    search.set('query', query);
    return this._jsonp.get('https://s.yimg.com/aq/autoc?region=US&lang=en-US&callback=JSONP_CALLBACK', {search})
          .map((response: Response) => response.json().ResultSet.Result);
  }
開發者ID:derekrjones,項目名稱:portfolio,代碼行數:7,代碼來源:quote.service.ts

示例4: Error

 .switchMap((): Observable<any> => {
     console.log("Fetching", url);
     return this.jsonp
         .request(url)
         .timeout(15000, new Error("Timed out"))
         .map((res: any) => res.json());
 })
開發者ID:fergusg,項目名稱:oxfloodwatch,代碼行數:7,代碼來源:data-service.ts

示例5: getData

  getData (symbol: string) {
    let year = this.date.getFullYear();
    let month = this.date.getMonth() + 1;
    let day = this.date.getDate();

    let startDate: string = [year - 1, month, day].join("-");
    let endDate: string = [year, month, day].join("-");

    let apiRootYahoo = "http://query.yahooapis.com/v1/public/yql?q=select%20*%20from%20yahoo.finance.historicaldata%20where%20symbol%20%3D%20%22";

    // let apiRoot = "http://marketdata.websol.barchart.com/getHistory.json";

    // var params = new URLSearchParams();
    //   params.set('key', '2bdfab4812fc5de3327d3495356cf383');
    //   params.set('symbol', symbol); // the user's search value
    //   params.set('type', 'daily');
    //   params.set('startDate', '20150311000000');
    //   params.set('format', 'json');
    //   params.set('callback', 'JSONP_CALLBACK');
    //
    // return this._jsonp
    //            .get(apiRoot, { search: params })
    //            .map(request => request.results.json());

    let fullURL = apiRootYahoo + symbol + "%22%20and%20startDate%20%3D%20%22" + startDate + "%22%20and%20endDate%20%3D%20%22" + endDate + "%22&format=json&diagnostics=true&env=store%3A%2F%2Fdatatables.org%2Falltableswithkeys&callback=JSONP_CALLBACK";



    return this._jsonp
               .get(fullURL)
               .map(request => request.json());
  }
開發者ID:philipyoo,項目名稱:trading-dashboard,代碼行數:32,代碼來源:stock-information.service.ts

示例6: URLSearchParams

loadAlbums(id) {
    let params = new URLSearchParams('callback=JSONP_CALLBACK&entity=album');
    params.set('id', id);
    params.set('country', this.setting.country.code);
    return this.jsonp.request('https://itunes.apple.com/lookup', {
      search: params
    }).map (response => response.json().results)
      .map(results => results.filter((item) => item.collectionType === 'Album'));
  }
開發者ID:AllanSmithee83,項目名稱:as-ionic2-iTunesApp,代碼行數:9,代碼來源:itunes.ts

示例7: 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 })
               .map((request) => request.json()[1]);
 }
開發者ID:dasaki-gr,項目名稱:angular2-coder,代碼行數:9,代碼來源:wikipediaservice.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:HansS,項目名稱:ng2Boilerplate-born2net,代碼行數: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})
                      .toPromise()
                      .then((res) => res.json()[1]);
 }
開發者ID:dilunika,項目名稱:angular2,代碼行數:11,代碼來源:promise.wiki.service.ts

示例10: search

 search(): any {
     var search = new URLSearchParams();
     //search.set('action', 'opensearch');
     //search.set('search', term);
     //search.set('format', 'json');
     //return this.jsonp.get('./showcase/portlet/data.json', { search}).map((request) => request.json()[1]);
     let url = './showcase/portlet/setting.json';            
     return this.jsonp
         .get(url, {})
         .map(request => this.result(request));
 }
開發者ID:racktime,項目名稱:glucosensWebApp,代碼行數:11,代碼來源:portletService.ts


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