I want to return a boolean value ,but the variable in the "if" condition is undefined.
function() {
this.menuDataService.getMenu()
.subscribe(res => {
this.mainMenus = res.MainMenus;
console.log(this.mainMenus);
});
console.log(this.mainMenus);
if(this.mainMenus == 1){
return true;
}
else {
return false;
}
}