要在Angular 4中调用WCF REST服务两次,你可以使用HttpClient模块来发送HTTP请求。下面是一个示例解决方法,其中包含了调用WCF REST服务两次的代码示例:
import { HttpClientModule } from '@angular/common/http';
@NgModule({
  imports: [
    HttpClientModule
  ],
  ...
})
export class AppModule { }
import { Component } from '@angular/core';
import { HttpClient } from '@angular/common/http';
@Component({
  selector: 'app-root',
  templateUrl: './app.component.html',
  styleUrls: ['./app.component.css']
})
export class AppComponent {
  constructor(private http: HttpClient) {}
  ngOnInit() {
    this.callWcfService();
  }
  callWcfService() {
    this.http.get('http://your-wcf-service-url/service1')
      .subscribe(response1 => {
        console.log(response1);
        
        this.http.get('http://your-wcf-service-url/service2')
          .subscribe(response2 => {
            console.log(response2);
          });
      });
  }
}
your-wcf-service-url替换为你实际的WCF服务URL。这样,当AppComponent初始化时,它将调用callWcfService()方法,该方法将依次调用WCF REST服务两次,并将响应打印到控制台中。
请注意,上述代码示例是基于Angular 4和HttpClient模块的。如果你使用的是其他版本的Angular,可能需要进行相应的修改。
下一篇:Angular 4动画下拉菜单