Skip to content

Instantly share code, notes, and snippets.

@jonathansolorzn
Created November 7, 2015 05:31
Show Gist options
  • Save jonathansolorzn/aaa3c17cf7f1b37706ff to your computer and use it in GitHub Desktop.
Save jonathansolorzn/aaa3c17cf7f1b37706ff to your computer and use it in GitHub Desktop.
Factory for READ products data.
(function () {
'use strict';
angular
.module( 'app.purchases.products' )
.factory( 'ReadProductFactory', ReadProductFactory );
ReadProductFactory.$inject = [ 'Restangular' ];
function ReadProductFactory( Restangular ) {
return {
detailProduct: detailProduct,
listProducts: listProducts
};
function detailProduct( data, success, fail ) {
Restangular
.one( '/purchases/products/', data.id )
.all( '/detail' )
.getList()
.then( success, fail );
}
function listProducts( data, success, fail ) {
Restangular
.all( '/purchases/products/list' )
.getList()
.then( success, fail );
}
}
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment