我正在使用cordova inappbrowser插件进行一个基于ionic的webview项目,我可以通过使用"ionic serve"命令正确运行它,但是当我试图在android上运行它时,它会在空白屏幕上卡住。
.controller("ExampleController", function ($scope) {
$scope.openCordovaWebView = function()
{
// Open cordova webview if the url is in the whitelist otherwise opens in app browser
window.open('https://google.com','_self','location=no');
};
你安装了吗
cordova-plugin-inappbrowser ?
终端类型:
cordova plugin list
中的项目根文件夹。还
cordova plugin
没问题。
安装好插件后,在View中试试:
<button class="button" ng-click="openInBrowser('https://www.google.com')">
GOOGLE
</button>
然后在JS
myApp.controller('ExampleController', ['$scope', '$ionicPlatform', '$cordovaInAppBrowser', function($scope, $ionicPlatform, $cordovaInAppBrowser){
$scope.openInBrowser = function(extUrl){
$ionicPlatform.ready(function() {
var options = {
location: 'yes',
clearcache: 'yes',
toolbar: 'yes'
};
$cordovaInAppBrowser.open(extUrl, '_system', options)
.then(function(event) {
// success
})
.catch(function(event) {
// error
});
}); // ./$ionicPlatform.ready
};//--------------------------------------
}]);