Angular 角度11:类型';认购';类型';中缺少以下属性;家庭数据';:

Angular 角度11:类型';认购';类型';中缺少以下属性;家庭数据';:,angular,http,get,Angular,Http,Get,我试图从后端服务器检索数据,但出现以下错误:“订阅”类型缺少“HomeData”类型中的以下属性:aSes、aggregatorChanges、announces、BeaconAnnounces等 我正在使用以下服务 export class HomeService { constructor(private http: HttpClient) { } getData(): Observable<HomeData>{ return this.http.get<Ho

我试图从后端服务器检索数据,但出现以下错误:“订阅”类型缺少“HomeData”类型中的以下属性:aSes、aggregatorChanges、announces、BeaconAnnounces等

我正在使用以下服务

export class HomeService {

  constructor(private http: HttpClient) { }


getData(): Observable<HomeData>{
  return this.http.get<HomeData>('https://bgpie.net/api/rrc/00');

}
}
我在组件中调用getData(),如下所示:

export class HomeComponent implements OnInit {
  elements!: HomeData;
  constructor(private http: HttpClient,
              private homeService: HomeService) {
   }

  ngOnInit(): void {
    this.elements = this.homeService.getData().subscribe((data: HomeData) => {this.elements = data; });
  }

我把所有这些都放在我的html模板中

<ul>
  <li *ngFor = "let element of elements">
    Total number of Sequences: <b>{{element.sequences}}</b>
    <br>Distinct Prefixes involved in Sequences: <b>{{element.prefixes}}</b>
    <br>BGP Updates involved in Sequences: /// (Announces: <b>{{element.announces}}</b>, Withdrawals: <b>{{element.withdraws}}</b>)
    <br>Total number of BGP Updates collected by RRC00 in 2019: /// (Announces: ///, Withdraws: ///)
    <br>Percentage of BGP Updates belonging to Sequences: /// (Announces: ///, Withdrawals: ///)
    <br>Distinct Collctor Peers (CPs) that observed at least a Sequences: <b>{{element.cPs}}</b>
    <br>Distinct ASes originating the prefexes involved in the Sequences: <b>{{element.aSes}}</b>
    <br>Number of AB-BA Sequences (whose AS-path contains pattern xAyBz and x'By'Az'): <b>{{element.containingLoops}}</b>
    <br>Sequences that are originated by an IPv4 Prefix: <b>{{element.prefixv4}}</b>
    <br>Sequences that are originated by an IPv6 Prefix: <b>{{element.prefixv6}}</b>
    <br>Sequences whose prefix is announced by more than one AS: <b>{{element.moreThanOneAsOrigin}}</b>
    <br>Sequences that contain at least one announcement with the BGP Path Attribute Aggregator set: <b>{{element.containsAggregator}}</b>
    <br>Sequences that contain at least two announcement with different values of the BGP Path Attribute Aggregator: <b>{{element.aggregatorChanges}}</b>
    <br>Sequences originated by a known beacon prefix: <b>{{element.beaconSequences}}</b>
    <br>BGP Updates originated by a known beacon prefix: <b>{{element.beaconAnnouncements + element.beaconWithdrawals}}</b> (Announcements: {{element.beaconAnnouncements}}, Withdrawals: {{element.beaconWithdrawals}})
    <br>Percentage of BGP Updates originated by a known beacon prefix: /// (Announcements: ///, Withdrawals: ///)
  </li>
</ul>
    序列总数:{{element.Sequences}
    序列中涉及的不同前缀:{{element.Prefixes}
    序列中涉及的BGP更新://(宣布:{{element.Announces}},撤回:{{element.drawss})
    2019年RRC00收集的BGP更新总数://(宣布://,撤回://)
    属于以下序列的BGP更新的百分比://(宣布://,撤回://)
    至少观察到一个序列:{{element.CPs}
    源自序列中涉及的前序的不同ASE:{element.ASes}
    AB-BA序列的数量(其AS路径包含模式xAyBz和x'By'Az'):{{element.containingLoops}
    由IPv4前缀发起的序列:{{element.prefixv4}
    由IPv6前缀发起的序列:{{element.prefixv6}
    其前缀由多个AS宣布的序列:{{element.moreThanOneAsOrigin}
    至少包含一个具有BGP路径属性聚合器集的公告的序列:{{element.containsAggregator}
    包含至少两个具有不同BGP路径属性聚合器值的公告的序列:{{element.aggregatorChanges}
    由已知信标前缀发起的序列:{{element.bea}
    由已知信标前缀发起的BGP更新:{{element.beaconAnnouncements+element.beaconDrawals}}(通知:{{element.beaconAnnouncements},撤回:{{{element.beaconDrawals})
    由已知信标前缀发起的BGP更新的百分比://(公告://,撤回://)

您正在将订阅分配给变量
元素
。相反,它应该是以下内容

ngOnInit():void{
此.homeService.getData()订阅(
(data:HomeData)=>{this.elements=data;},
(错误:any)=>{/*句柄错误*/}
);
}

您正在将订阅分配给变量
元素
。相反,它应该是以下内容

ngOnInit():void{
此.homeService.getData()订阅(
(data:HomeData)=>{this.elements=data;},
(错误:any)=>{/*句柄错误*/}
);
}

Error ha现已消失,但数据仍不会显示,如果在浏览器上打开开发人员控制台,则会出现以下错误:-从源站“”访问位于“”的XMLHttpRequest已被CORS策略阻止:请求的资源上不存在“Access Control Allow origin”头-GET net::ERR_失败该问题与CORS有关,与问题完全无关。您需要调整响应头和/或在前端设置代理。您可以从这里开始:错误ha现已消失,但数据仍不会显示,如果我在浏览器上打开开发人员控制台,则会出现以下错误:-从源服务器“”访问位于“”的XMLHttpRequest已被CORS策略阻止:请求的资源上不存在“Access Control Allow origin”标头-GET net::ERR_失败该问题与CORS有关,与问题完全无关。您需要调整响应头和/或在前端设置代理。你可以从这里开始:
<ul>
  <li *ngFor = "let element of elements">
    Total number of Sequences: <b>{{element.sequences}}</b>
    <br>Distinct Prefixes involved in Sequences: <b>{{element.prefixes}}</b>
    <br>BGP Updates involved in Sequences: /// (Announces: <b>{{element.announces}}</b>, Withdrawals: <b>{{element.withdraws}}</b>)
    <br>Total number of BGP Updates collected by RRC00 in 2019: /// (Announces: ///, Withdraws: ///)
    <br>Percentage of BGP Updates belonging to Sequences: /// (Announces: ///, Withdrawals: ///)
    <br>Distinct Collctor Peers (CPs) that observed at least a Sequences: <b>{{element.cPs}}</b>
    <br>Distinct ASes originating the prefexes involved in the Sequences: <b>{{element.aSes}}</b>
    <br>Number of AB-BA Sequences (whose AS-path contains pattern xAyBz and x'By'Az'): <b>{{element.containingLoops}}</b>
    <br>Sequences that are originated by an IPv4 Prefix: <b>{{element.prefixv4}}</b>
    <br>Sequences that are originated by an IPv6 Prefix: <b>{{element.prefixv6}}</b>
    <br>Sequences whose prefix is announced by more than one AS: <b>{{element.moreThanOneAsOrigin}}</b>
    <br>Sequences that contain at least one announcement with the BGP Path Attribute Aggregator set: <b>{{element.containsAggregator}}</b>
    <br>Sequences that contain at least two announcement with different values of the BGP Path Attribute Aggregator: <b>{{element.aggregatorChanges}}</b>
    <br>Sequences originated by a known beacon prefix: <b>{{element.beaconSequences}}</b>
    <br>BGP Updates originated by a known beacon prefix: <b>{{element.beaconAnnouncements + element.beaconWithdrawals}}</b> (Announcements: {{element.beaconAnnouncements}}, Withdrawals: {{element.beaconWithdrawals}})
    <br>Percentage of BGP Updates originated by a known beacon prefix: /// (Announcements: ///, Withdrawals: ///)
  </li>
</ul>