Sfoglia il codice sorgente

sort dates properly

David 9 anni fa
parent
commit
b71e52527c
1 ha cambiato i file con 9 aggiunte e 1 eliminazioni
  1. 9 1
      front/controllers/rawCtrl.js

+ 9 - 1
front/controllers/rawCtrl.js

@@ -2,7 +2,15 @@ app.controller('rawCtrl', ['$scope', '$http', function ($scope, $http) {
 
 	$scope.update = function() {
 		$http.get('back/list/raw').success(function(data) {
-	   		$scope.rawlist = data.list; 
+	   		$scope.rawlist = data.list.filter(function(f) {
+				return (f.date === +f.date) //Check if it's a number
+			}).map(function(f) {
+				var item = f;
+				item.date = item.date*1000;
+				return item;
+			}).sort(function(a,b) {
+				return ( b.date > a.date ? 1 : -1 );
+			});
 		});
 	};