user1835326 user1835326 - 10 months ago 49
AngularJS Question

Angular Service Error not returning the control to then

I have a question regarding angular service. I have a controller and a service and if in service(which is calling a backend code) and I get an error. It is not transferring the control back to controller as if not returning a response.
How can I solve it

service call in controller

//some Code

my service

this.myresp = function(obj){ $,obj).success(function(data,status,headers,config){
this.resp = data;
this.resp = data;
return this.myresp;

Answer Source

a promise takes in 2 callbacks a success and a fail . You can return your error from the second callback

    function(){return 'success';}, 
    function(){return 'error'});

Don't know if this can help you because you did not include any code