Actually you are too close but you missing that when you write
Restangular.extendModel('cars', function(obj) {
obj.extraMethod = function() { console.log('method added'); };
return obj;
});
this only extend object with 'cars' route...
but your return object's route is whatever your id parameter...
try this code...
factory('Car', function(Restangular) {
Restangular.extendModel('cars', function(obj) {
obj.extraMethod = function() { console.log('method added'); };
return obj;
});
return {
show: function(id) {
return Restangular.one('cars', id).get();
}
};
}
this time return object's route is cars and it will have extramethod()
...