ionic 1 Themeable Browser not opening in android d

2019-03-06 14:06发布

问题:

Here my flow...

I added both ios and androidplatform

Installed it cordova plugin add cordova-plugin-themeablebrowser

My example pdf : http://www.pdf995.com/samples/pdf.pdf

that plugin in github: https://github.com/initialxy/cordova-plugin-themeablebrowser

My index.html :

 <ion-pane>
      <ion-header-bar class="bar-stable">
        <h1 class="title">Ionic Blank Starter</h1>
      </ion-header-bar>
      <ion-content ng-controller="FileOpenerController">

       <button class="button button-icon loginnavbtn" ng-click="openpdf()">pdf open</button>
      </ion-content>
    </ion-pane>

my .js

    app.controller('FileOpenerController', function($scope, $ionicPlatform,$themeablebrowser) {

    var options = {
                toolbar: {
                    height: 44,
                    color: '#cdcdcd'
              },
                title: {
                    color: '#003264ff',
                    showPageTitle: true
              },
                closeButton: {
                    image: 'close',
                    imagePressed: 'close_pressed',
                    align: 'left',
                    event: 'closePressed'
              },
                backButton: {
                    image: 'back',
                    imagePressed: 'back_pressed',
                    align: 'left',
                    event: 'backPressed'
              },
                forwardButton: {
                    image: 'forward',
                    imagePressed: 'forward_pressed',
                    align: 'left',
                    event: 'forwardPressed'
              },
                closeButton: {
                    image: 'close',
                    imagePressed: 'close_pressed',
                    align: 'left',
                    event: 'closePressed'
              },
                menu: {
                    image: 'menu',
                    imagePressed: 'menu_pressed',
                    title: 'Select for quick menu',
                    cancel: 'Cancel',
                    align: 'right',
                    items: [
                             {
                               event: 'btn1Pressed',
                               label: 'Button1'
                             },
                             {
                               event: 'btn2Pressed',
                               label: 'Button2'
                             }]
                 };
               }

    function openpdf() {


// dont know how to call my pdf url....not able to get the correct code...
}


    });

I have few doubts.

Does my $themeablebrowser is corrrect that i have defined in app.controller.

don't know how to code inside my click method to open my pdf in Themeable url

Thanks in advance

回答1:

you have to add urls like this

 $scope.openpdf= function(){
    cordova.ThemeableBrowser.open('here goes your url', '_blank', {...}
 }

sample here

 $scope.openpdf= function(){
    cordova.ThemeableBrowser.open(' http://www.pdf995.com/samples/pdf.pdf', '_blank', {
        statusbar: {
            color: '#ffffffff'
        },
        toolbar: {
            height: 44,
            color: '#f0f0f0ff'
        },
        title: {
            color: '#003264ff',
            showPageTitle: true
        },
        backButton: {
            image: 'back',
            imagePressed: 'back_pressed',
            align: 'left',
            event: 'backPressed'
        },
        forwardButton: {
            image: 'forward',
            imagePressed: 'forward_pressed',
            align: 'left',
            event: 'forwardPressed'
        },
        closeButton: {
            image: 'close',
            imagePressed: 'close_pressed',
            align: 'left',
            event: 'closePressed'
        },
        customButtons: [
            {
                image: 'share',
                imagePressed: 'share_pressed',
                align: 'right',
                event: 'sharePressed'
            }
        ],
        menu: {
            image: 'menu',
            imagePressed: 'menu_pressed',
            title: 'Test',
            cancel: 'Cancel',
            align: 'right',
            items: [
                {
                    event: 'helloPressed',
                    label: 'Hello World!'
                },
                {
                    event: 'testPressed',
                    label: 'Test!'
                }
            ]
        },
        backButtonCanClose: true
    }).addEventListener('backPressed', function(e) {
        alert('back pressed');
    }).addEventListener('helloPressed', function(e) {
        alert('hello pressed');
    }).addEventListener('sharePressed', function(e) {
        alert(e.url);
    }).addEventListener(cordova.ThemeableBrowser.EVT_ERR, function(e) {
        console.error(e.message);
    }).addEventListener(cordova.ThemeableBrowser.EVT_WRN, function(e) {
        console.log(e.message);
    });
    }