FileTransfer未定义 - AngularJS

时间:2016-06-15 15:12:25

标签: angularjs cordova cordova-plugins

我目前正在尝试在用户的移动设备上下载CSV文件。我正在使用cordova库。

当我尝试启动下载文件的功能时,我发生错误。

我的控制器中的功能

        <HelixToolkit:HelixViewport3D.Camera>
            <PerspectiveCamera 
                Position="{Binding CameraPosition,Mode=TwoWay}"
                LookDirection="{Binding CameraDirection,Mode=TwoWay}"
                UpDirection="{Binding Camera.UpDirection}"
                FieldOfView="{Binding Camera.FieldOfView}"
             />
        </HelixToolkit:HelixViewport3D.Camera>

    </HelixToolkit:HelixViewport3D>

我已经在依赖项中添加了CordovaFileTransfer和cordovaFile,我已经尝试删除android并在之后再添加它。 如果您需要更多信息,请告诉我

我的index.html:

  $scope.downloadFilefunction = function () {

      console.log("started");

      var source = $scope.downloadCSV();
      var fileName = source.split("/").pop();
      var filePath = 'file:///storage/emulated/0/';
      console.log("filepath :::");
      var options = {};
      $cordovaFileTransfer.download(source, filePath, options, true).then(
          function (result) {
              console.log("success", JSON.stringify(result));
          }, function (err) {
              console.log("error", JSON.stringify(err));
          });
  }

我的观点:

  <!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8">
    <meta name="viewport" content="initial-scale=1, maximum-scale=1, user-scalable=no, width=device-width">
    <title></title>
    <link href="lib/ionic/css/ionic.css" rel="stylesheet">
    <link href="css/style.css" rel="stylesheet">

    <!-- IF using Sass (run gulp sass first), then uncomment below and remove the CSS includes above
    <link href="css/ionic.app.css" rel="stylesheet">-->

    <!-- ionic/angularjs js -->
    <script src="lib/ionic/js/ionic.bundle.js"></script>
    <script src='lib/signature_pad/signature_pad.js'></script>

    <!-- cordova script (this will be a 404 during development) -->
      <script src="lib/ngCordova/dist/ng-cordova.min.js"></script>
    <script src="lib/ngCordova/dist/ng-cordova.js"></script>

    <script src="lib/ng-csv/build/ng-csv.js"></script>
<script src="https://rawgithub.com/eligrey/FileSaver.js/master/FileSaver.js" type="text/javascript"></script>
    <script src="cordova.js"></script>
  <script src="js\require.js"></script>
    <!-- your app's js -->
    <script src="js/app.js"></script>
    <script src="js/controllers.js"></script>
  </head>

  <body ng-app="starter">
    <ion-nav-view></ion-nav-view>
  </body>
</html>

有人知道我怎么能避免这个错误,或至少能够下载文件。提前谢谢你。

0 个答案:

没有答案