I have the following javascript code which I am unable to pass into "inner function".
I'm able to retrieve u1 and p1 values in the "Outer Function" console while I'm unable to retrieve it in the function which is nested inside 'confirm'.
Console prints Inner Function's u1 and p1 as undefined.
The code snippet as shown:
function alertFunc(vara, varb) {
console.log("Timeout!");
var u1 = vara;
var p1 = varb;
console.log("Outer Function: " + u1 + " , " + p1);
confirm(u1, p1);
function confirm(u1, p1) {
var confirmPopup = $ionicPopup.confirm({
title: 'Network Time-Out',
template: 'Check your network connection and try again.',
okText: 'Retry'
});
confirmPopup.then(function(res, u1, p1) {
if (res) {
$scope.loading = true;
console.log("Inner Function: " + u1 + " , " + p1);
loginz(u1, p1);
} else {
console.log('Cancelled');
}
});
}
}
What could be the problem as I'm sure I passed in the variables in. Could it be during the 'confirmPopup', I did not pass the values in? Would really appreciate any pointers!