findUser(id:number):boolean{
var bool :boolean =false
this.companyService.query().subscribe((result)=>{
for (let i = 0; i < result.json.length; i++) {
try {
if( id == result.json[i].user.id)
{
console.log('id-user:',id ,'user in company:',result.json[i].user.id,'company :',result.json[i].id )
bool = true
}
}
catch (error) {}
}
console.log('final bool value:',bool)
})
console.log(bool)
if(bool) return true;else return false
}
confirmDeletion(login) {
this.userService.find(login).subscribe((response)=>{
const id =response.id
console.log('result :', this.findUser(id))
})
}
- result : false
- id-user: 7202
- user in company: 7202 company : 5151
- final bool value : true
Why am I always receiving a false
as the output?