久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

<i id='6nSf2'><tr id='6nSf2'><dt id='6nSf2'><q id='6nSf2'><span id='6nSf2'><b id='6nSf2'><form id='6nSf2'><ins id='6nSf2'></ins><ul id='6nSf2'></ul><sub id='6nSf2'></sub></form><legend id='6nSf2'></legend><bdo id='6nSf2'><pre id='6nSf2'><center id='6nSf2'></center></pre></bdo></b><th id='6nSf2'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='6nSf2'><tfoot id='6nSf2'></tfoot><dl id='6nSf2'><fieldset id='6nSf2'></fieldset></dl></div>

  • <small id='6nSf2'></small><noframes id='6nSf2'>

      <tfoot id='6nSf2'></tfoot>
        • <bdo id='6nSf2'></bdo><ul id='6nSf2'></ul>

        <legend id='6nSf2'><style id='6nSf2'><dir id='6nSf2'><q id='6nSf2'></q></dir></style></legend>

        Angular 2 (Ionic 2):攔截 ajax 請(qǐng)求

        Angular 2 (Ionic 2): intercept ajax requests(Angular 2 (Ionic 2):攔截 ajax 請(qǐng)求)
        <tfoot id='ZU5ax'></tfoot>
            • <bdo id='ZU5ax'></bdo><ul id='ZU5ax'></ul>

              1. <legend id='ZU5ax'><style id='ZU5ax'><dir id='ZU5ax'><q id='ZU5ax'></q></dir></style></legend>
                1. <small id='ZU5ax'></small><noframes id='ZU5ax'>

                    <tbody id='ZU5ax'></tbody>
                  <i id='ZU5ax'><tr id='ZU5ax'><dt id='ZU5ax'><q id='ZU5ax'><span id='ZU5ax'><b id='ZU5ax'><form id='ZU5ax'><ins id='ZU5ax'></ins><ul id='ZU5ax'></ul><sub id='ZU5ax'></sub></form><legend id='ZU5ax'></legend><bdo id='ZU5ax'><pre id='ZU5ax'><center id='ZU5ax'></center></pre></bdo></b><th id='ZU5ax'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='ZU5ax'><tfoot id='ZU5ax'></tfoot><dl id='ZU5ax'><fieldset id='ZU5ax'></fieldset></dl></div>
                2. 本文介紹了Angular 2 (Ionic 2):攔截 ajax 請(qǐng)求的處理方法,對(duì)大家解決問(wèn)題具有一定的參考價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)吧!

                  問(wèn)題描述

                  使用 Angular 1.x 可以使用以下代碼攔截所有 ajax 請(qǐng)求:

                  With Angular 1.x is possible to intercept all ajax requests with some code like:

                  $httpProvider.interceptors.push('interceptRequests');
                  ...
                  var app_services = angular.module('app.services', []);
                     app_services.factory('interceptRequests', [function () {
                     var authInterceptorServiceFactory = {};
                     var _request = function (config) {
                     //do something here
                     };
                     var _responseError = function (rejection) {
                     //do something here
                     }
                     authInterceptorServiceFactory.request = _request;
                     authInterceptorServiceFactory.responseError = _responseError;
                     return authInterceptorServiceFactory;
                  }]);
                  

                  Angular 2 中是否有類似的(或開(kāi)箱即用的)功能?

                  Is there anything similar (or out-of-the-box) in Angular 2?

                  推薦答案

                  一種方法可以是擴(kuò)展 HTTP 對(duì)象來(lái)攔截調(diào)用:

                  An approach could be to extend the HTTP object to intercept calls:

                  @Injectable()
                  export class CustomHttp extends Http {
                  
                    request(url: string | Request, options?: RequestOptionsArgs): Observable<Response> {
                      console.log('request...');
                      return super.request(url, options).catch(res => {
                        // do something
                      });        
                    }
                  
                    get(url: string, options?: RequestOptionsArgs): Observable<Response> {
                      console.log('get...');
                      return super.get(url, options).catch(res => {
                        // do something
                      });
                    }
                  }
                  

                  并按如下所述進(jìn)行注冊(cè):

                  and register it as described below:

                  bootstrap(AppComponent, [HTTP_PROVIDERS,
                      new Provider(Http, {
                        useFactory: (backend: XHRBackend, defaultOptions: RequestOptions) => new CustomHttp(backend, defaultOptions),
                        deps: [XHRBackend, RequestOptions]
                    })
                  ]);
                  

                  您可以利用例如 catch 運(yùn)算符來(lái)捕獲錯(cuò)誤并在全局范圍內(nèi)處理它們...

                  You can leverage for example the catch operator to catch errors and handle them globally...

                  看到這個(gè) plunkr:https://plnkr.co/edit/ukcJRuZ7QKlV73jiUDd1?p=preview.

                  See this plunkr: https://plnkr.co/edit/ukcJRuZ7QKlV73jiUDd1?p=preview.

                  這篇關(guān)于Angular 2 (Ionic 2):攔截 ajax 請(qǐng)求的文章就介紹到這了,希望我們推薦的答案對(duì)大家有所幫助,也希望大家多多支持html5模板網(wǎng)!

                  【網(wǎng)站聲明】本站部分內(nèi)容來(lái)源于互聯(lián)網(wǎng),旨在幫助大家更快的解決問(wèn)題,如果有圖片或者內(nèi)容侵犯了您的權(quán)益,請(qǐng)聯(lián)系我們刪除處理,感謝您的支持!

                  相關(guān)文檔推薦

                  Use IScroll in Angular 2 / Typescript(在 Angular 2/Typescript 中使用 IScroll)
                  anime.js not working in Ionic 3 project(Anime.js 在 Ionic 3 項(xiàng)目中不起作用)
                  Ionic 3 - Update Observable with Asynchronous Data(Ionic 3 - 使用異步數(shù)據(jù)更新 Observable)
                  Angular 2: file not found on local .json file(Angular 2:在本地 .json 文件中找不到文件)
                  In Ionic 2, how do I create a custom directive that uses Ionic components?(在 Ionic 2 中,如何創(chuàng)建使用 Ionic 組件的自定義指令?)
                  Use ViewChild for dynamic elements - Angular 2 amp; ionic 2(將 ViewChild 用于動(dòng)態(tài)元素 - Angular 2 amp;離子2)
                  <legend id='yoxqm'><style id='yoxqm'><dir id='yoxqm'><q id='yoxqm'></q></dir></style></legend>

                    <tbody id='yoxqm'></tbody>
                  <tfoot id='yoxqm'></tfoot>
                    • <small id='yoxqm'></small><noframes id='yoxqm'>

                      1. <i id='yoxqm'><tr id='yoxqm'><dt id='yoxqm'><q id='yoxqm'><span id='yoxqm'><b id='yoxqm'><form id='yoxqm'><ins id='yoxqm'></ins><ul id='yoxqm'></ul><sub id='yoxqm'></sub></form><legend id='yoxqm'></legend><bdo id='yoxqm'><pre id='yoxqm'><center id='yoxqm'></center></pre></bdo></b><th id='yoxqm'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='yoxqm'><tfoot id='yoxqm'></tfoot><dl id='yoxqm'><fieldset id='yoxqm'></fieldset></dl></div>

                          • <bdo id='yoxqm'></bdo><ul id='yoxqm'></ul>
                          • 主站蜘蛛池模板: 免费人成在线观看网站 | 精品国产女人 | 成人av高清 | 99re视频在线免费观看 | 一级片在线观看视频 | 亚洲精品久久久一区二区三区 | 野狼在线社区2017入口 | 日韩中文一区二区三区 | 一区二区三区在线 | 二区欧美| 精品一区二区三区在线观看 | 欧美多人在线 | 成人精品免费视频 | 国产中文视频 | 成人免费视频观看视频 | 国产精品国产三级国产aⅴ中文 | 久久久久久高潮国产精品视 | 91久久 | 玩丰满女领导对白露脸hd | 欧美午夜影院 | 一级黄色毛片 | 欧美国产精品一区二区三区 | 亚洲视频国产 | 一区二区三区免费在线观看 | 一级毛片免费视频 | 亚洲日韩中文字幕一区 | 毛片免费在线 | 成年女人免费v片 | 精品一级 | 在线视频国产一区 | 91视频导航| 在线成人免费视频 | 欧美成年黄网站色视频 | 黄视频在线网站 | 嫩草视频免费 | 美女视频一区二区三区 | 伊人久久综合 | 美女天天操 | 亚洲精品99久久久久久 | 亚洲一区高清 | av网站推荐 |