Search code examples
angularjsrestangular

Where to implement Restangular's Extend Model


I'm currently migrating my application from $resouce to Restangular and I'm having trouble understanding where extendModel should be implemented.

Having read through the slides available here on slide 46 it shows the following two snippets.

 Restangular.extendModel('cars', function(car){
    return Car.extend(car);
 });


module.factory('Car', function(Exteder){
function Car(){}

Car.prototype.chargeFuel = function(amount){

}

Car.extend = Extender.for('car')

return Car
});

My question is where should the extendModel function actually be declared? Should it be in the App.config or in a controller somewhere? I've been through the documentation several times now and I can't seem to find a concrete answer.


Solution

  • So after much searching I believe I've found the correct place to implement this as being in the app.config section of the angular application.

    Simply pass the RestangularProvider as a parameter and use RestangularProvider.extendModel()