I have these methods
function successHandler(result/*,deferred*/) {
var strResult = "";
if (typeof result === 'object') {
strResult = JSON.stringify(result);
} else {
strResult = result;
}
var mes = "SUCCESS: \r\n" + strResult;
NotificationService.alert(mes, "پيغام", "تاييد");
//deferred.resolve();
}
function errorHandler(error/*,deferred*/) {
var mes = "ERROR: \r\n" + error;
NotificationService.alert(mes, "خطا", "تاييد");
//deferred.reject();
}
function init() {
//var deferred = $q.defer();
inappbilling.init(successHandler, errorHandler, { showLog: true });
//return deferred.promise;
}
I need to create a deffer object and pass it to the success and error handler (like what I commented), since the callbacks have another argument by default I am really confused how to do that