LoopBackApiBundle icon indicating copy to clipboard operation
LoopBackApiBundle copied to clipboard

API platform + loopBackApi + ng admin + sort filter

Open Gu3 opened this issue 9 years ago • 0 comments

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;
                },
            };
        });

Gu3 avatar Apr 07 '16 09:04 Gu3