0

I know this sort of questions have been answered before also . But I still am not able get completely over it .

Via a server call I am getting a list back. I am trying to get the count of the list by length property.

But it is always undefined.

        $http(request)
            .success(function (response) {
                if (response != "Failed!" && response != "FileAlreadyUploaded") {
                        $scope.pleaseWait = { "display": "none" };

                        console.log("Succeeds");

                        UploadDataServices.setInvalidRecordsCount(response.GroupMembershipInputList.length);

If I see in the browser console , I get to see the property.

enter image description here

What am I doing wrong here ?

StrugglingCoder
  • 4,781
  • 16
  • 69
  • 103
  • 1
    Possible Duplicate of [How do I return the response from an asynchronous call?](http://stackoverflow.com/questions/14220321/how-do-i-return-the-response-from-an-asynchronous-call) – Tushar Jun 08 '16 at 07:29
  • What's in the `setInvalidRecordsCount` ? – Anik Islam Abhi Jun 08 '16 at 07:30
  • @AnikIslamAbhi .. I am setting the returned length in Angular service variable. – StrugglingCoder Jun 08 '16 at 07:32
  • @Tushar I am not asking to figure out a way to return from an async call . I am just not understanding why length is undefined even though the array has items within it. So it is not duplicate. – StrugglingCoder Jun 08 '16 at 07:34

2 Answers2

1

Try capturing the response in one variable and check the variable value using console.log and if that variable has value try passing the variable instead of the response.

S. Divya
  • 91
  • 9
1

Sorry guys. It was mistake on my part only . It just happened there was another nested array object with just similar name .. GroupMembershipUploadInputList and that had it's length .

StrugglingCoder
  • 4,781
  • 16
  • 69
  • 103