I am facing an issue where I need to access a variable in one function from another function. My code structure is as follows:
NOTE: The value for submitData.alcohol is obtained from elsewhere in my code.
angular.module('app',['ui.router'])
.controller('infoCtrl',['$scope','$http',functioninfoCtrl($scope,$http){
var result;
$scope.one = function(){
if(submitData.alcohol=='1'){
result = 'Yes';
}else{
result = 'No';
}
};
$scope.two = function(){
console.log(result);
}
}]);
However, when I check the log, I see that the result is 'undefined'. How can I resolve this issue?