2016-08-23 4 views
1

외부 사이트를 webview에로드하는 ionic app가 있습니다. URL로드가 완료되기 전에 webview가로드 될 때마다 빈 페이지가 표시됩니다. URL이 완료된 후에 만 ​​webview를 표시하고 싶습니다. 나 또한 loadstart에 대한 eventlistener, 그 윈도우가 닫힐 때 URL이 충돌하고 이온 애플 리케이션 홈 화면으로 돌아갈 것을 의미합니다, 내 에뮬레이터에서 작동하지만 내 실제 장치에 그냥 기호로 빈 페이지를 보여줍니다.URL로드가 완료 될 때까지 내 webview를 숨기려고합니다.

$scope.login = function() 
     { 
     //check if network is connected before sending initial request 
     if(monitor.isOffline()) 
     { 
      var alertPopup = $ionicPopup.alert({ 
      title: 'Network Error!', 
      template: "Your Network is Offline, please connect and try again" 
      }); 
     } 

     //show spinner while loading page 
     $scope.show = function() { 
      $ionicLoading.show({ 
      template: '<p>Loading...</p><ion-spinner></ion-spinner>' 
      }); 
     }; 

     //hide spinner 
     $scope.hide = function(){ 
      $ionicLoading.hide(); 
     }; 


     //send initial request 
     AuthService.login($scope.user).then(
      function(home) 
      { 
      $scope.show($ionicLoading); 
      if(monitor.isOnline()) 
      { 
       $scope.show($ionicLoading); 

       var ref = window.open(home, '_blank', 'location=no,toolbar=no'); 

       ref.addEventListener('loadstart', function (event) 
       { 
       if(event.url == "http://mobile.map.education/logout") 
       { 
        ref.close(); 
       } 

       }); 
       ref.addEventListener('loaderror', function (event) 
       { 
       var alertPopup = $ionicPopup.alert({ 
        title: 'Network Error', 
        template: "Oops,Error with your network" 
       }); 

       ref.close(); 

       }); 

       $scope.hide($ionicLoading); 

       //watch network state 
       monitor.startWatching(); 
      } 
      if(monitor.isOffline()) 
      { 
       var alertPopup = $ionicPopup.alert({ 
       title: 'Network Error', 
       template: "Oops,Error with your network" 
       }) 
      } 
      }, 
      function (errMsg) 
      { 
      var alertPopup = $ionicPopup.alert({ 
       title: 'Login failed!', 
       template: errMsg 
      }); 
      }) 
      .catch(function() 
      { 
      var alertPopup = $ionicPopup.alert({ 
       title: 'Login failed!', 
       template: 'Server not responding' 
      }) 
       .finally(function ($ionicLoading) 
       { 
       $scope.hide($ionicLoading); 
       }); 
      }); 
     }; 
+0

당신이 원하는 페이지가 로딩 될 때까지'ref' 윈도우를 숨겨 둡니다. – gianlucatursi

+0

예, ref를 숨기고 싶습니다. – lagfvu

답변

관련 문제