这是代码段。请帮助我。
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);
});
}
答案 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);
});