我收到错误TS2339:类型为any []的属性“总计”不存在

时间:2018-09-23 16:47:02

标签: angular typescript

这是代码段。请帮助我。

 response: any[] = [];
proResponse: any[] = [];


 erase(res: any[]): void {res.length = 0; this.response.total = 0; }


 onSubmit(searchForm: FormGroup) {

       this.showNhide = true;
       this.proResponse = [];
       this.proName = '';
       this.searchService.searchNResult(searchForm.value).subscribe((result: any[]) => {
      console.log('Result comes' + result.toString());
      this.response = result;
    }, (error: any) => {
      console.log('search result Loading Error :' + error);
    });
  }

1 个答案:

答案 0 :(得分:0)

应为 any 的响应类型,而不是 any[] 。应如下所示,

this.searchService.searchNResult(searchForm.value).subscribe((result: any) => {
      console.log('Result comes' + result.toString());
      this.response = result;
    }, (error: any) => {
      console.log('search result Loading Error :' + error);
});