Angular 2:如何在一次调用中绑定四个服务

时间:2017-02-27 08:35:13

标签: html angular typescript

我已经提到two backend service on a success of the first service,它解决了我的两个后端服务的问题。但是我有三个后端服务,第一个服务成功,第二个服务应该调用,第二个服务成功,第三个应该服务呼叫。 请帮我。

service.ts

Firstservice

gethrdata(param)
   {
    var respone: any;
   let headers = new Headers();
     headers.append('Content-Type', 'application/json');
     let authToken = localStorage.getItem('auth_token');
     console.log(authToken);
     headers.append('X-auth-Token', authToken)
     return this._http.post('http://localhost:8080/ada/api/v1/client/'+param+'/hrdata', '', {headers} )
      /*.map(res => res.json())*/
      .map((res) => {
      respone = res;
      console.log(respone); 
      return respone; 
      });

   }

Secondservice

 getflagloa(param)
   {
    var respone: any;
   let headers = new Headers();
     headers.append('Content-Type', 'application/json');
     let authToken = localStorage.getItem('auth_token');
     console.log(authToken);
     headers.append('X-auth-Token', authToken)
     return this._http.get('http://localhost:8080/api/v1/client/'+param+'/loa', { headers })
      .map(res => res.json())
      .map((res) => {
      respone = res;
      console.log(respone); 
      return respone; 
      });

   }

Thirdservice

 insertloa(param)
   {
    var respone: any;
   let headers = new Headers();
     headers.append('Content-Type', 'application/json');

     let authToken = localStorage.getItem('auth_token');
     console.log(authToken);
     headers.append('X-auth-Token', authToken);
    /* let options = new RequestOptions({headers:headers});*/
     return this._http.post('http://localhost:8080/api/v1/client/'+param+'/loadata', '', {headers} )
      /*.map(res => res.json())*/
      .map((res) => {
      respone = res;
      console.log(respone); 
      return respone; 
      });

   }

现在如何在prevoius服务成功时调用这些服务。

0 个答案:

没有答案