When I call the function "classTableData" on a button click, my allData variable becomes undefined. The problem seems to be that it processes the next line of code without waiting for the results, causing allData to remain empty. Can anyone provide some assistance with this issue?
function classTableData(){
loadStudentPDFData().then(function (results) {
studentPDFData = results.pdfData;
});
var allData = studentPDFData;
$log.log("AllData"+allData.length);
}
function loadStudentPDFData() {
var deferred = q.defer();
var core5PDFData=angular.copy(core5InstructionPlanner);
core5PDFData.loadPDFSection('all', function() {
deferred.resolve({pdfData:core5PDFData.dataSource('all').data()});
});
return deferred.promise;
}