I am writing a simple java script function inside a controller of angularJS,
$scope.getwork = function(taskData){
$scope.workData = workData;
var i =0;
do{
var getworkQuery = CommunicationsService.getGetworkValue($scope.workData.requestId, $scope.workData.waitTime);
getworkQuery.query({},function(resp1,$scope){
$scope.getTaskValue=resp1;
console.log("inside getTaskAttri ");
console.log($scope.getTaskValue);
console.log($scope.getTaskValue.status);
console.log($scope.getTaskValue.errorMessage);
i++;
});
}while($scope.getworkValue.status == 'processing' && i<3);
}
Here, I am getting the error,
TypeError: Cannot read property 'status' of undefined
at Object.$scope.getTaskAttri (http://127.0.0.1:7002/vtmui/views/js/Controllers/GetWorkController.js:128:31)
at http://127.0.0.1:7002/vtmui/views/js/Controllers/GetTaskController.js:102:24
at http://127.0.0.1:7002/vtmui/views/lib/angular/angular-resource.js:413:30
at wrappedCallback (http://127.0.0.1:7002/vtmui/views/lib/angular/angular.js:6995:59)
at http://127.0.0.1:7002/vtmui/views/lib/angular/angular.js:7032:26
at Object.Scope.$eval (http://127.0.0.1:7002/vtmui/views/lib/angular/angular.js:8218:28)
at Object.Scope.$digest (http://127.0.0.1:7002/vtmui/views/lib/angular/angular.js:8077:25)
at Object.Scope.$apply (http://127.0.0.1:7002/vtmui/views/lib/angular/angular.js:8304:24)
at done (http://127.0.0.1:7002/vtmui/views/lib/angular/angular.js:9357:20)
at completeRequest (http://127.0.0.1:7002/vtmui/views/lib/angular/angular.js:9531:7) angular.js:5930
inside getTaskAttri GetTaskController.js:122
Resource {requestId: "2641991", status: "failure", errorMessage: "Communication failure during execution process.", waitTime: 0, workLsit: Array[0]…}
failure
Communication failure during execution process.
console.log
inside the do..while
loop is getting displayed but it is showing undefined error in the while loop for the variable $scope.getworkValue.status
:
while($scope.getworkValue.status == 'processing' && i<3);
Any idea how to solve this?