var appCounts = 0;
applicationsService.getApplicationCountByJob(job.id).then((appcount) => {
appCounts = appCounts + appcount;
});
company.applications = appCounts;
appCount在company.applications = appCounts;
请让我知道如何解决这个问题。
答案 0 :(得分:0)
你的函数getApplicationCountByJob可能是异步的,意思是
company.applications = appCounts;
在
之前执行appCounts = appCounts + appcount;
进入另一个,然后让它工作:
var appCounts = 0;
applicationsService.getApplicationCountByJob(job.id)
.then((appcount) => {
appCounts = appCounts + appcount;
})
.then(() => {
company.applications = appCounts;
});