离子1主题浏览器无法在Android设备中打开

时间:2017-05-10 03:25:25

标签: angularjs ionic-framework browser hybrid-mobile-app

我的流程......

我添加了ios and android平台

已安装cordova plugin add cordova-plugin-themeablebrowser

我的示例pdf:http://www.pdf995.com/samples/pdf.pdf

github中的插件:https://github.com/initialxy/cordova-plugin-themeablebrowser

我的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>

我的.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...
}


    });

我很怀疑。

我的$themeablebrowser是否正确,我已在app.controller中定义。

不知道如何在我的click方法中编码以在Themeable url

中打开我的pdf

提前致谢

1 个答案:

答案 0 :(得分:0)

你必须添加像这样的网址

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

这里的样本

 $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);
    });
    }