LoopBackApiBundle
LoopBackApiBundle copied to clipboard
API platform + loopBackApi + ng admin + sort filter
Hi ! I had some trouble to use the order filter with ng admin and restangular. After some tests, I found with $httpprovider, if someone have the same problem :
$httpProvider.interceptors.push(function() {
return {
request: function(config) {
if( typeof (config.params) !== 'undefined'
&& config.params._sortField
&& config.params._sortDir){
if(config.url.split('?').length > 1)
config.url = config.url + '&filter[order] ['+config.params._sortField+']='+config.params._sortDir
else
config.url = config.url + '?filter[order]['+config.params._sortField+']='+config.params._sortDir
delete config.params._sortField;
delete config.params._sortDir;
}
return config;
},
};
});