I'm new using Restangular and I don't understand how resolve the promises using my own service. I' ve been trying to return the customGET
method but in my controller the response it's a object that contain all the methods of the restangular resource, so i don't understand how get the response data. I inspect the network activity and the data it's retrieved.
My Service
angular
.module('Form29')
.service('Form29Service', Service);
Service.$inject = ['Restangular'];
function Service(Restangular) {
this.serviceResource = Restangular.all('forms');
this.getForm29 = getForm29;
function getForm29(_month, _year, _type) {
var params = {
rut: '76195496',
month: _month,
year: _year,
type: _type
};
return this.serviceResource.customGET('',params);
}
}
My Controller
angular
.module('Form29')
.controller('Form29Controller', Controller);
Controller.$inject = ['Form29Service'];
function Controller(Form29Service) {
var vm = this;
vm.submitForm = submitForm;
function submitForm(month, year, type){
Form29Service.getForm29(month, year, type).then(showForm);
}
function showForm(response){
console.log(response);
}
}
I think the issue that that you try to make customGet
with empty path, in that case you can easily do simple get(queryParams)
that will return promise for you.