diff options
Diffstat (limited to 'testapi/opnfv_testapi/ui/app.js')
-rw-r--r-- | testapi/opnfv_testapi/ui/app.js | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/testapi/opnfv_testapi/ui/app.js b/testapi/opnfv_testapi/ui/app.js index a64bfcc..ada7577 100644 --- a/testapi/opnfv_testapi/ui/app.js +++ b/testapi/opnfv_testapi/ui/app.js @@ -34,6 +34,36 @@ angular .module('testapiApp') + .service('sortService', function(){ + + this.sortFunction = function(data, field, ascending){ + if(ascending){ + data.sort(function(a,b) { + if (a[field].toLowerCase() > b[field].toLowerCase()) { + return -1; + } + if (a[field].toLowerCase() < b[field].toLowerCase()) { + return 1; + } + return 0; + }); + }else{ + data.sort(function(a,b) { + if (a[field].toLowerCase() < b[field].toLowerCase()) { + return -1; + } + if (a[field].toLowerCase() > b[field].toLowerCase()) { + return 1; + } + return 0; + }); + } + return data + } + }); + + angular + .module('testapiApp') .directive('dynamicModel', ['$compile', '$parse', function ($compile, $parse) { return { restrict: 'A', |