Mike 8 years ago
parent
commit
246bbff610
1 changed files with 11 additions and 3 deletions
  1. 11 3
      yanshi/www/js/controllers.js

+ 11 - 3
yanshi/www/js/controllers.js

xqd xqd
@@ -51,9 +51,9 @@ starter.controller('homeCtrl',["$scope",'$http','$timeout','$ionicLoading','$sta
 		$http({
     		method:'get',
     		url:config.server+'/list',
-    	}).success(function(newItem){
+    	}).success(function(newItems){
 	        $timeout(function(){
-	        	$scope.excals = newItem
+	        	$scope.excals = newItems
 	        	$ionicLoading.hide();
 	        });
     	}).error(function(){
@@ -122,15 +122,23 @@ starter.controller('showCtrl',["$scope",'$ionicHistory','$state','$timeout','$st
 	$scope.doSelected = function(name){
 		if(localStorage.refreshtime!=0){
 			newtimer = $timeout(function() {
-       			$scope.doSelected(name);
+				$http({
+		    		method:'get',
+		    		url:config.server+'/list',
+		    	}).success(function(newItems){
+	        		if(newItems.length>0&&name)
+       				$scope.doSelected(newItems[newItems.length-1]);
+		    	})
 			}, localStorage.refreshtime*1000);
 		}else{
+       		$scope.selectedName(name);
       		$timeout.cancel(mytimer);
 		}
 		$scope.selectedName(name);
 	}
     
 	$scope.selectedName = function(name){
+    	$scope.name = name;
 		$ionicLoading.show({
             template: '加载中...',
         });