属性 'subscribe' 类型“订阅”不存在

Property 'subscribe' does not exist on type 'Subscription

这里通过使用 GET 方法,我得到了已申请的职位列表。此代码来自appliedJobsPage

this.getjobs.getAppliedjobList().subscribe(data => {
      this.appliedjobs = data;
    })

这是我的供应商页面getJobs

getAppliedjobList() {
    let headers = new Headers();
    headers.append('Content-Type','application/json');
    return this.http.get('http://localhost:3000/api/appliedjobs',{headers: headers})
    .map(res => res.json())
    .subscribe(data => {
      this.jobslist = data;
    });
  } 

我遇到错误

Property 'subscribe' does not exist on type 'Subscription'. Did you mean 'unsubscribe'?

您遇到此错误是因为您已经订阅了 observable。

map(res => res.json())
    .subscribe(data => {
      this.jobslist = data;
    });

如果您使用的是 angular 版本 5 或更高版本,则不需要此 map(res => res.json())。 无论如何,您需要在您的服务中删除对可观察对象的订阅,以便您可以在您的组件中订阅可观察对象。在您的服务中删除以下内容:

.subscribe(data => {
          this.jobslist = data;
        });