angular.module('app', ['restangular']).run(["Restangular", function (Restangular) {
Restangular.setTransformOnlyServerElements(true);
Restangular.addElementTransformer('items', false, function(obj) {
if (!obj.fromServer) {
console.debug("I wouldn't expect to get here");
}
return obj;
});
Restangular.one('items',0).get().then(function(c) {
//do something.
});
}]);
If you run this code, you'll see that you do in fact get local object in the transform callback. This appears to only be the case in 1.4.0, because I run the same code in 1.3.1 just fine.
This appears to be because the call for transformElem added a new parameter force:
This value is hardcoded to be true in both of the restangularizeElem and restangularizeCollection methods.
It appears this change came from https://github.com/mgonto/restangular/issues/581 but callbacks to both addElementTransformer and extendModelalso go through the restangularizeElem and restangularizeCollection functions
For example:
If you run this code, you'll see that you do in fact get local object in the transform callback. This appears to only be the case in 1.4.0, because I run the same code in 1.3.1 just fine.
This appears to be because the call for
transformElem
added a new parameterforce
:This value is hardcoded to be true in both of the
restangularizeElem
andrestangularizeCollection
methods.It appears this change came from https://github.com/mgonto/restangular/issues/581 but callbacks to both
addElementTransformer
andextendModel
also go through therestangularizeElem
andrestangularizeCollection
functionsEdit: fixed a typo.