【问题标题】:Open file explorer in ionic via $ionicActionSheet.show()通过 $ionicActionSheet.show() 在 ionic 中打开文件资源管理器
【发布时间】:2017-02-02 14:06:11
【问题描述】:

当用户单击 Ionic ActionSheet 中的按钮时,我正在尝试在我的 ionic 应用程序中打开文件资源管理器。这可以通过将<input type="file"> 放入 HTML 模板中简单地完成。但我在操作表中给出了两个选项

  1. 打开相机
  2. 打开文件资源管理器 我使用$cordovaCamera 插件打开相机,但我不知道如何打开文件探索。这是我的代码供参考

$ionicActionSheet.show({
    buttons: [{ text: 'Open File Explorer //or <input type="file">' },
    { text: 'Open Camera' }],
     buttonClicked: function(buttons) {
     if(buttons == 0)
     {
      // what to do here ?
     return true;
     }
     if(buttons == 1)
    {
     $scope.takeImage(Camera.PictureSourceType.CAMERA);
     return true;
     }}
     })

【问题讨论】:

    标签: javascript angularjs node.js cordova ionic-framework


    【解决方案1】:

    我通过插入 &lt;input type="file" id="fileupload" style="display:none"&gt; 并在我使用的控制器中实现了这一点

     if(buttons == 0)
       {
        // what to do here ?
        document.getElementById('fileupload').click()
             ...
        }
    

    我希望这可以帮助某人。

    【讨论】:

      【解决方案2】:

      使用cordova-plugin-file插件处理文件管理器

      https://cordova.apache.org/docs/en/latest/reference/cordova-plugin-file/

      使用安装插件

      cordova plugin add cordova-plugin-file

      然后使用deviceready事件下提供的函数。

      More info : https://github.com/apache/cordova-plugin-file
      

      【讨论】:

      • 我已经在使用这个插件来上传图片文件或使用&lt;input type="file"&gt; 问题是如何在$ionicActionSheet.show() 中制作一个按钮
      猜你喜欢
      • 2020-07-30
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-10-20
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多