restangular
restangular copied to clipboard
restangularizeElement with extendModel
Hi,
I have defined some services to get data from a REST API and in those services I use the extendModel function to add extra functions to the received data:
regressionApp.service('ResultService', function (Restangular) {
Restangular.extendModel('results', function(obj) {
return angular.extend(obj, {
aFuncion: function() {
return "a value";
}
});
});
return {
getResults: function () {
return Restangular.all('results');
}
}
});
But now I have one such result embedded in another restangular model, this result is raw json. So I want to convert it to the restangular object with the function aFunction. To convert I tried Restangular.restangularizeElement(null, jsonObject, 'results'), after calling this function I get a restangular object, but the function defined in extendModel cannot be called.
How can I convert the json to the correct restangular object?
Thank you,
The extendModel was in an external service that was not loaded.