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()
});
答案 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);
});