IONIC使用inappbrowser loadstart无法正常工作

时间:2016-11-16 05:30:45

标签: ionic-framework inappbrowser

IONIC使用inappbrowser无法正常工作

var ref=   $cordovaInAppBrowser.open(url, '_self', options);        
ref.addEventListener('loadstart', function(event) {  
    alert(event.url); $ionicLoading.show() 
}); 
ref.addEventListener('loadstop', function(event) {  
    alert(event.url); 
    $ionicLoading.hide() 
});

1 个答案:

答案 0 :(得分:1)

尝试:

$ionicLoading.show();
$cordovaInAppBrowser.open(url, '_blank', inAppBrowserOptions);
  $rootScope.$on('$cordovaInAppBrowser:loadstop', function(e, event){
    $cordovaInAppBrowser.show();
    $timeout(function(){$ionicLoading.hide()},2000);
  });

对于inAppBrowserOptions:

  .config(function($cordovaInAppBrowserProvider) {
    var defaultOptions = {
      location: 'yes',
      clearcache: 'no',
      hardwareback: 'yes',
      toolbar: 'no'
    };
    document.addEventListener("deviceready", function () {
      $cordovaInAppBrowserProvider.setDefaultOptions(defaultOptions)
    }, false);
  });