Whenever I try to run the code below, I encounter an error message stating that getConfigDetails
is not a function. My goal is to have the function getConfigDetails
return a promise only if the isConfigLoaded
variable is true; otherwise, it should continue calling itself until it is true.
var getConfigDetails = function () {
if ($rootScope.isconfigloaded) {
configDetails.roles = $rootScope.orgConfig.roles.slice();
configDetails.departments = $rootScope.orgConfig.departments.slice();
configDetails.levels = $rootScope.orgConfig.levels.slice();
configDetails.designation = $rootScope.orgConfig.designation.slice();
return Promise.resolve();
} else {
setTimeout(function(){
getConfigDetails();
},200);
}
};
getConfigDetails().then(function(){});