jjdltc / jjdltc-cordova-plugin-zip

A plugin to zip and unzip files or directories
MIT License
23 stars 25 forks source link

Error when running code #5

Closed whitecat closed 8 years ago

whitecat commented 8 years ago

When I add the function

$cordovaZip
        .unzip(
          src, // https://github.com/MobileChromeApps/zip/blob/master/tests/tests.js#L32
          dest // https://github.com/MobileChromeApps/zip/blob/master/tests/tests.js#L45
        ).then(function () {
          elem.innerHTML = "success"
          console.log('success');
        }, function () {
          console.log('error');
        }, function (progressEvent) {
          // https://github.com/MobileChromeApps/zip#usage
          console.log(progressEvent);

I get the the following: Error: undefined is not an object (evaluating '$window.zip.unzip')

Are there additional packages that need to be installed to make $window.zip defined?

jjdltc commented 8 years ago

I think you are in the wrong page @whitecat I'm not part of MobileChromeApps, and this plugin does not work as you describe in your post. Anyway I will be glad if you decide to migrate to this plugin ;)

whitecat commented 8 years ago

What is the difference between yours and this one? I tried the following code and I also got a similar error:

    $scope.unzip = function() {
      var elem = document.getElementById("result");
      elem.innerHTML = "pushed"
      src = "data/translink/recent.zip"
      dest = "data/translink/"
      $JJzip.unzip(
          src, 
          dest 
        ).then(function () {
          elem.innerHTML = "success"
          console.log('success');
        }, function () {
          console.log('error');
        }, function (progressEvent) {
          console.log(progressEvent);
        });
jjdltc commented 8 years ago

They are just different @whitecat (In plain words, they don't fork me and I don't fork them, so is just a different approach for the same problem), More detailed:

  1. I Didn't make a wrapper for Angular, so $JJzip.unzip does not apply
  2. The function receive as second parameter an object, not a string, (you can see that in the readme )
  3. I don't handle yet the progress event

Anyway, you are still invite tu use this one if you prefer, just please read the doc (Readme) first ;)