I am new to angularjs
, currently I am facing one issue, which is like -
I am calling one service that is -
if($scope.tab === "1"){
$scope.loadreports();
$scope.loaddocumentForHighlighting();
}
$scope.loadreports = function(){
uploadService.loadReports(uploadService.currentFileName, $scope.documentType, jdCurrentFileName)
.then(function (response) { uploadservice.setreprtdata(response) },function (error) {
$scope.loadingReports = false;
$scope.errorMessage = error.status + " : " + error.statusText;
if (error.status === 401) {
loginService.authenticationError();
}
}
Now ,
$scope.loaddocumentforhighlighting = function(){
uploadService.getDocumentAsHTML($scope.documentType, uploadService.currentFileName)
.then(function (data) {}, .finally(function ( console.log(uploadservice.getreportdata()) ) {
$scope.showDocumentReloadPanel = false;
});
}
Now,here what is happening When first call is of the loadreports
then it takes some time to get the response from server. But in that method I have one set and that I want to use in the second method. But before that the second methods gets executed. So, get in that method gives me undefined
. But the thing is that I get the response of the first method as well. But Not in the time. SO, How can I resolve this issue ?