2017-02-27 64 views
1

我實施了部署服務到我的離子應用程序(我使用離子1),它工作正常,現在我想向用戶顯示下載剩餘時間或進度條他們不認爲該應用程序是凍結的。 下面是Ionic 1部署服務進度條

var deployFunction = function() { 
     $ionicDeploy.check().then(function(snapshotAvailable){ 

      if (snapshotAvailable) { 
      // When snapshotAvailable is true, you can apply the snapshot 
       MainService.startSpinner("Downloading Updates");//this shows a loading image indicating that the download started 

       //applying the snapshot 
       $ionicDeploy.download() 
       .then(
        function() { 
         MainService.stopSpinner(); 
         MainService.startSpinner("Extracting"); 
         $ionicDeploy.extract() 
         .then(
          function(){ 
           MainService.stopSpinner(); 
           $ionicDeploy.load(); 
          }, function(error) { 
           console.log("ERROR EXTRACT "+error); 
           // Error extracting 
          }, function(progress) { 
           // progress of extracting 
           console.log('extraction progress '+progress); 
          } 
         ); 
        }, function(error){ 
         //download error 
         console.log("ERROR Downloading "+error); 
        }, function(progress) { 
         //download progress 
         console.log('download progress '+progress); 
        } 
       ); 
      } 
     }); 
    } 

我讀過的地方,進展函數返回一個整數... 部署的功能,但它是不是和我不知道如何獲取有關下載軟件,旁邊的信息它開始或完成。 任何幫助將備將來參考此基於this文檔解決理解

回答

1

,該代碼將

$ionicDeploy.download({ 
        onProgress: function(p) { 
         console.log(p); 
        } 
       }) 
       .then(
        function() {... 

我嘗試過了,控制檯記錄的號碼從1到100,指示下載進度。

+0

這做了工作。謝謝 –