aftab
aftab

Reputation: 545

Can not read property of $promise then undefined?

I am calling factory from controller trying to resolve $promise if its thenable get response.data , but i am getting an error "can not read property of 'then' undefined". I am new to AngularJS please let me know where i have coded wrong.

mfactory.js

 getAlldocs : function (assessmentId){
                        $http.get('app/upload/getallDoc/' +assessmentId);
                      }

main.js

  $scope.riskAssessmentDTO.riskAssessmentKey = id;
        rcsaAssessmentService.getAlldocs(id,function(response){
          assessmentData = response.data;
        });

Upvotes: 0

Views: 57

Answers (1)

Chrillewoodz
Chrillewoodz

Reputation: 28368

You need to return the $http call from your function:

getAlldocs : function (assessmentId){
  return $http.get('app/upload/getallDoc/' +assessmentId);
}

Or you won't return a promise at all.

Upvotes: 2

Related Questions