嗨,我收到错误
concat is not a function
我正在尝试的是
searchResults:any; // inside class export
results:any
this.candidateSearch.postSearch(this.searchedInput,"candidateSearch").then((result)=>{
this.results = result;
console.log(this.results.details);
this.searchResults = this.searchResults.concat(this.results); // throwing error
}, (err) => {
});
我的结果采用以下格式:
{
"details": [{
"company_name": "Cybrain Software Solutions",
"skills": "php,laravel",
"package": "15 lakh",
"location": "Bengaluru",
"industry": "Software",
"job_type": "permanent"
}, {
"company_name": "Floret Media Pvt Ltd",
"skills": "php",
"package": "10 lakh",
"location": "Bengaluru",
"industry": "software",
"job_type": "per"
}]
}
我的问题:我想合并之前的结果
编辑:我希望 searchResults
数组在连接后采用以下格式 {"details":[{},{},{}]}
最佳答案
您需要初始化数组
searchResults:any = [];
关于angular - 为什么 concat 在合并 2 个对象数组时会抛出错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46968223/