简体   繁体   中英

Cordova inappbrowser not working in android

I'm working on a ionic based webview project by using cordova inappbrowser plugin, I could run it properly by using "ionic serve" command but when i try to run it on android it stucks at blank screen.

.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'); 

};

Have you install

cordova-plugin-inappbrowser ?

In terminal type:

cordova plugin list

in your project's root folder. Also

cordova plugin 

works fine.

try this after you have the plug in installed, in View:

<button class="button" ng-click="openInBrowser('https://www.google.com')">
    GOOGLE
</button>

then in the 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
        };//--------------------------------------

 }]);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM