Here is my code:
module.factory('baseService', function ($http, $q) {

    // instantiate initial object
    var baseService = function () {
    };
    baseService.prototype.execute = function (url, webService, method,
params) {
        params = typeof params !== "undefined" ? params : {};
        var deferred = $q.defer();
        var response = $http({
            method: "post",
            dataType: "json",
            data: JSON.stringify(params),
            headers: {
                'Content-Type': "application/json; charset=utf-8",
            },
            url: url + 'services/' + webService + "/" + method
        });
        response.success(function (data) {
            deferred.resolve(data);
        });
        response.error(function (data) {
            alert('Error');
        });
        // Return the promise to the controller
        return deferred.promise;
    };
    return baseService;
});
And in Controller:
baseService.prototype.execute("webservice",
"method").then("successfunction");
function successfunction(data){}

How would I change my baseService?

Thanks

On Sat, Sep 12, 2015 at 2:06 AM Emmanuel DEMEY <[email protected]>
wrote:

> Hi
>
> Maybe the second method of the then method. Or catch ?
>
> Manu
> @EmmanuelDemey
> Le 11 sept. 2015 20:43, "mark goldin" <[email protected]> a écrit :
>
>> Yes, correct. I am talking about that. Thus, the question is: what is a
>> design pattern to catch errors?
>>
>> On Fri, Sep 11, 2015 at 1:31 PM Emmanuel DEMEY <[email protected]>
>> wrote:
>>
>>> Can you give more precision ? If your talking about the $http().error()
>>> function, yes it has been deprecated in angular 1.4.
>>> Le 11 sept. 2015 18:54, "mark goldin" <[email protected]> a écrit :
>>>
>>>> Is that true or it's old news?
>>>>
>>>> Thanks
>>>>
>>>> --
>>>>
>>> You received this message because you are subscribed to the Google
>>>> Groups "AngularJS" group.
>>>> To unsubscribe from this group and stop receiving emails from it, send
>>>> an email to [email protected].
>>>
>>>
>>>> To post to this group, send email to [email protected].
>>>> Visit this group at http://groups.google.com/group/angular.
>>>> For more options, visit https://groups.google.com/d/optout.
>>>>
>>> --
>>> You received this message because you are subscribed to a topic in the
>>> Google Groups "AngularJS" group.
>>> To unsubscribe from this topic, visit
>>> https://groups.google.com/d/topic/angular/pU8sW45XZxo/unsubscribe.
>>> To unsubscribe from this group and all its topics, send an email to
>>> [email protected].
>>> To post to this group, send email to [email protected].
>>> Visit this group at http://groups.google.com/group/angular.
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "AngularJS" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to [email protected].
>> To post to this group, send email to [email protected].
>> Visit this group at http://groups.google.com/group/angular.
>> For more options, visit https://groups.google.com/d/optout.
>>
> --
> You received this message because you are subscribed to a topic in the
> Google Groups "AngularJS" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/angular/pU8sW45XZxo/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to
> [email protected].
> To post to this group, send email to [email protected].
> Visit this group at http://groups.google.com/group/angular.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"AngularJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.

Reply via email to