0

I'm currently using a factory to pass in a response to a controller. The issue that i am having...is that the response doesnt become defined until i press submit.

my factory (responseHandler):

return {
        setMessages: function(response) {
            if (response ===  undefined) {
                return false;
            } else {
                return response;
            }
        }
    };

my controller:

$scope.messages = responseHandler.setMessages();

it works when i manually put a string into the setMessages function but doesnt work when i pass in a response. Any help would be great

thanks

EDIT:

in the response i am getting an array of just some string for ex..

[  
   {  
      "message":"Title required"
   },
   {  
      "message":"No first and last name"
   },
   {  
      "message":"No address info"
   },
   {  
      "message":"Cannot submit"
   }
]
RIYAJ KHAN
  • 15,032
  • 5
  • 31
  • 53
jeremy
  • 433
  • 1
  • 8
  • 30
  • How u passing response.Can u please share script – RIYAJ KHAN Mar 16 '17 at 17:01
  • I am getting my response from a service that returns an array of strings. When i go to my dev console, i see that i am getting my responses returned into the factory...however i am not getting them passed to the controller – jeremy Mar 16 '17 at 17:10
  • Possible duplicate of [How to use $http.successCallback response outside callback in angularJs](http://stackoverflow.com/questions/35275451/how-to-use-http-successcallback-response-outside-callback-in-angularjs) – georgeawg Mar 17 '17 at 00:33

1 Answers1

0

I dont know what you are trying to get as response.

You are calling a function that need a parameter response.

You have to provide this parameter in order to get a response.

It will not make sense since the same given parameter will be returned without any computation.

Delly Fofie
  • 304
  • 2
  • 9
  • edited...my response just contains an array of strings that gets passed in the function i am calling the factory – jeremy Mar 16 '17 at 16:43